Resolving

Forward Resolve (from Name to Address)

Onchain

Assuming you have minted test.bera with correct data (or correct setAddr), you need to call resolve on the universal resolver passing the dns encoded form of the name and the function you want to call (in this case, addr(bytes node)). Code can be found HERE

With Viem

https://viem.sh/docs/ens/actions/getEnsAddress.html

const ensAddress = await publicClient.getEnsAddress({
  name: normalize('test.bera'),
})

Reverse Resolve (from Address to Name)

Onchain

Assuming you have minted test.bera with correct data (or correct setAddr), you need to call reverse on the universal resolver passing the dns encoded form of the reverse address. Check ENS documentation if you need more, but Anvil has your back.

With Viem

https://viem.sh/docs/ens/actions/getEnsName

const ensName = await publicClient.getEnsName({
  address: '<your address>',
})
return ensName.replace(".bera", ".🐻⛓️") // => test.🐻⛓️

Please note “ensName.replace(".bera", ".🐻⛓️") // => test.🐻⛓️”. Without this line you will get test.bera. Emojis are much nicer than .bera, but a few limitations prevented us from doing it directly on chain.

Other Providers

Re-Own, WalletConnect, Ethers.js, etcetc.

The contracts are ENS-compatible so it’s really easy to configure them. If you do the work and you want to share it, please reach out and we’ll add it to this page.

Last updated