Skip to content

Resolve with ENS

A handles.link name resolves like any other ENS name. Your library needs to support wildcard names (ENSIP-10) and offchain lookups (ERC-3668). viem and ethers v6 support both.

This works once handles.link is live; see Status. Until then the example returns null.

ENS lives on Ethereum mainnet, so connect to mainnet even if you send on another chain. Pass the chain you want an address for as a coin type:

import { createPublicClient, http } from 'viem';
import { mainnet, base } from 'viem/chains';
import { toCoinType } from 'viem';
const client = createPublicClient({ chain: mainnet, transport: http() });
const address = await client.getEnsAddress({
name: 'octocat.github.handles.link',
coinType: toCoinType(base.id),
});

address is the holder of octocat on GitHub, as recorded on Base. It is null if nobody owns the handle on Base.

Without coinType, you get the address on Ethereum mainnet.

Paste the name into the recipient field. Wallets that support ENS subnames with offchain lookups, such as MetaMask, resolve it the same way.

ENS and IdentityRegistry give the same answer. Which one to use depends on where the name comes from:

  • Use ENS when a person types or pastes a name, or when you want names to work in wallets you do not control.
  • Use IdentityRegistry from your own code and contracts. It needs no gateway, and it can also tell you when the handle was proved. See Resolve a handle.