Imports
registry
The library exports a registry object with the required methods. You can import it like this:
import { registry } from '@leapwallet/name-matcha'
services
The library exports a services
object with the available services:
import { services as nameMatcha } from '@leapwallet/name-matcha'
It looks like this:
const services = {
icns: 'icns',
ibcDomains: 'ibcDomains',
stargazeNames: 'stargazeNames',
archIds: 'archIds',
spaceIds: 'spaceIds',
sns: 'sns',
nibId: 'nibId',
degeNS: 'degeNS'
}
Name Resolution
resolve
For resolving a name to address, you can use the resolve
method. It takes two arguments:
- The name to query
- The service to query against
const address = await nameMatcha.resolve('leap_cosmos.osmo', services.icns)
console.log(address); // osmo19vf5mfr40awvkefw69nl6p3mmlsnacmmzu45k9
resolveAll
To resolve a name to an address, for all the available services, you can use the resolveAll
method. It takes one argument:
- The name to query
const address = await nameMatcha.resolveAll('leap_cosmos.osmo')
console.log(address);
The output will be an object with the service as key and the address as value:
{
icns: 'osmo19vf5mfr40awvkefw69nl6p3mmlsnacmmzu45k9',
ibcDomains: null,
stargazeNames: null,
archIds: null,
spaceIds: null,
sns: null,
nibId: null,
degeNS: null,
bidds: null
}
Name Lookup
lookup
For getting the name associated to an address, you can use the lookup
method. It takes two arguments:
- The address to query
- The service to query against
const name = await nameMatcha.lookup('osmo19vf5mfr40awvkefw69nl6p3mmlsnacmmzu45k9', services.icns)
console.log(name); // leap_cosmos.osmo
lookupAll
To get the name associated to an address, for all the available services, you can use the lookupAll
method. It takes one argument:
- The address to query
const names = await nameMatcha.lookupAll('osmo19vf5mfr40awvkefw69nl6p3mmlsnacmmzu45k9')
The output will be an object with the service as key and the name as value:
{
icns: 'leap_cosmos.osmo',
ibcDomains: 'leapwallet.osmo',
stargazeNames: 'messi.osmo',
archIds: null,
spaceIds: null,
sns: null,
nibId: null,
degeNS: 'ligma.pp',
bidds: null
}
Switch Network
By default, the library uses the mainnet
network. To switch network, you can use the setNetwork
method. It takes one argument:
- The network to use
Here's an example:
nameMatcha.setNetwork('testnet')
Custom RPC Endpoints
Name Matcha comes with default RPC endpoints for each service.
Error Handling
The library throws errors when something goes wrong. The library throws errors of type MatchaError
. It is built on top of the Error
class, and has an additional property type
of type MatchaErrorType
.
import nameMatcha, { MatchaError, MatchaErrorType } from '@leapwallet/name-matcha'
try {
const name = await nameMatcha.lookup('osmo19vf5mfr40awvkefw69nl6p3mmlsnacmmzu45k9', services.icns)
} catch (error: MatchaError) {
if (error.type === MatchaErrorType.NOT_FOUND) {
alert('Name not found')
}
}
Supported Chains
- IBC Domains (opens in a new tab)
- ICNS (opens in a new tab)
- Stargaze Names - All Chains are Supported
- ArchId - Archway
- SpaceId (opens in a new tab) - Supports .inj and .sei domains
- SNS (opens in a new tab) - Injective .sol domains
- NIB ID (opens in a new tab) - .nibi domains on Nibiru
- DegeNS (opens in a new tab) - Degen Name Service on Sei Network
- Bidds Decentralized Domains (opens in a new tab) - Coreum .core domains