ENS Logo
Docs

Address Lookup

The RNS Protocol aims to make it easy to use The Root Network. It does this by providing a simple way to use human-readable names instead of long machine-readable addresses.

Getting the users EOA or FuturePass Address
Forward Lookup

The goal here is to take a name, such as legend.root, and convert it to an address, such as 0x2ac7d999ae4ceae1f1dbe497c12e64f1f6b0f231.

legend.root➡️0x2ac...f231

The simplest thing you can do is start with a name, and resolve it to an address. We call this a "forward lookup". Think of places where users can enter names, such as sending transactions, chatting, etc.

Forward Resolution
import { ethers } from 'ethers';
import { networks } from 'rootnameservice'

const provider = new ethers.providers.JsonRpcProvider('https://root.rootnet.live/archive', networks.root);

// legend.root -> 0x03E53414a65AF0723D8dAb6dFBA768E061E5d81f
provider.resolveName(
  'legend.root'
).then(console.log)

import { createPublicClient, defineChain, http } from 'viem'
import { addresses } from 'rootnameservice'
import { normalize } from 'viem/ens'

const root = defineChain({
  id: 7668,
  name: 'The Root Network',
  nativeCurrency: { name: 'Ripple', symbol: 'XRP', decimals: 18 },
  rpcUrls: {
    default: {
      http: ['https://root.rootnet.live/archive'],
    },
  },
  contracts: {
    ...addresses[7668],
  },
  subgraphs: {
    ens: {
      url: 'https://subgraph.rootnameservice.com/subgraphs/name/graphprotocol/ens/graphql',
    },
  },
  testnet: true,
})

const client = createPublicClient({
  chain: root,
  transport: http(),
})
console.log(addresses)

client.getEnsAddress({
  name: normalize("legend.root"),
}).then(console.log)