Usage

1. Resolve a domain name

You can get address from domain name with a single request:

const address = await web3name.getAddress('dottaiko.taiko')
// expect: '0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa'

Multichain address resolution

Domain resolution for other chains can be provided by adding coinType param to getAddress().

import { convertEVMChainIdToCoinType } from '@ensdomains/address-encoder'
const address = await web3name.getAddress('dottaiko.taiko', {coinType: convertEVMChainIdToCoinType(1)})
// expect: 0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa

2. Resolve an address

There are optional parameters in the method to select your target chain or TLD (top-level Domain).

By providing chain IDs, you can resolve addresses on selected chains and get an available domain name from all TLDs deployed on these chains.

// Resolve an address from Gnosis Chiado
const name = await web3name.getDomainName({
  address: '0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa',
  queryChainIdList: [167000],
})
// expect: taikons.taiko

By providing TLDs, address can be resolved from the selected TLDs and get an available TLD primary name.

// Resolve an address from .gno TLD
const name = await web3name.getDomainName({
  address: '0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa',
  queryTldList: ['taiko'],
})
// expect: taikons.taiko

3. Record

Domain text records can be fetched by providing domain name and the key. For example, the avatar record of spaceid.bnb is returned from this method given key name avatar:

const record = await sid.getDomainRecord({ name: 'dottaiko.taiko', key: 'avatar' })

4. Metadata

Domain metadata can be fetched by SDK directly.

// requesting
const metadata = await web3Name.getMetadata({ name: 'dottaiko.taiko' })

Use your own RPC

We are using popular public RPC services by default to make it easier to use. But in some cases developers may prefer to use arbitrary RPC, so we provide optional parameter rpcUrl for each function that allows developers to use their own RPC to make requests.

For example, you can put custom rpcUrl as a parameter in getAddress function.

// Use custom RPC url (https://rpc.taiko.xyz)
const address = await web3name.getAddress('dottaiko.taiko', {
  rpcUrl: 'https://rpc.taiko.xyz',
})
// expect: '0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa'

For other functions, it's also possible to have a custom rpcUrl in the request.

// Use custom RPC url (https://rpc.taiko.xyz)
const address = await web3name.getMetaData('dottaiko.taiko', {
  rpcUrl: 'https://rpc.taiko.xyz',
})
// expect: '0x0DD664928b33FB1507eC00bE3b593CDb9c50D9aa'

Last updated