Integrating using our SDK
You can access the package at this link: https://www.npmjs.com/package/@cronosid/croidjs?activeTab=code
Before you can begin interacting with Cronos ID, you will need to obtain a reference to the CROID registry.
import CROID, { getCroidAddress } from '@cronosid/croidjs'
const croid = new CROID({ provider, croidAddress: getCroidAddress('25') }) // Cronos Mainnet Chain Id
croid.name('cronos.cro').getAddress() // 0x123
var address = await croid.name('cronos.cro').getAddress();
While 'regular' resolution involves mapping from a name to an address, reverse resolution maps from an address back to a name. Cronos ID supports reverse resolution to allow applications to display Cronos ID names in place of hexadecimal addresses.
const address = '0x1234...';
let croidName = null;
({ name: croidName } = await croid.getName(address))
// Check to be sure the reverse record is correct. skip check if the name is null
if(croidName == null || address != await croid.name(croidName).getAddress()) {
croidName = null;
}
default - CROID
getCroidAddress
getResolverContract
getCROIDContract
namehash
labelhash
name(name: String) => Name
- Returns a Name Object, that allows you to make record queries.
resolver(address: CronosAddress) => Resolver
- Returns a Resolver Object, allowing you to query names from this specific resolver. Most useful when querying a different resolver that is different than is currently recorded on the registry. E.g. migrating to a new resolver
async getName(address: CronosAddress) => Promise<Name>
- Returns the reverse record for a particular Cronos address.
async getOwner() => Promise<CronosAddress>
- Returns the owner/controller for the current CROID name.
async getResolver() => Promise<CronosAddress>
- Returns the resolver for the current CROID name.
async getAddress(coinId: String) => Promise<CronosAddress>
- Returns the address for the current CROID name for the coinId provided.
async getContent() => Promise<ContentHash>
- Returns the contentHash for the current CROID name.
async getText(key: String) => Promise<String>
- Returns the text record for a given key for the current CROID name.
address
- Static property that returns current resolver address
name(name) => Name
- Returns a Name Object that hardcodes the resolver
If you have any questions about the integration with Cronos ID Domain, drop us a message on our Discord server and we will get in touch with you!
Last modified 29d ago