Documentation
Usage

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:

  1. The name to query
  2. 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:

  1. 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:

  1. The address to query
  2. 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:

  1. 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:

  1. 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