Reverse address resolution

Finding the domain associated with an address consists of X steps:

  1. Obtain the identifier of the address reverse records.

    Generate the RNS domain for a given account's reverse records. Convert the address to hexadecimal representation in lower-case, and append addr.reverse. For instance, the address 0x112234455c3a32fd11230c42e7bccd4a84e02010 might have its reverse records associated at 112234455c3a32fd11230c42e7bccd4a84e02010.addr.reverse.

    Use namehash algorithm with the reverse record domain to get the identifier of the address.

  2. Get its resolver contract.

    Use resolver(bytes32)

  3. Detect if contract supports name(bytes32) interface via ERC-165 interface detection.

    Use supportsInterface(bytes4) with interface ID: 0x691f3431

    ERC-165 spec

  4. Query for name resolution.

    Use name(bytes32) with the domain identifier.

    name(bytes32) spec


function reverseResolve (address) {
  const reverseName = `${address.slice(2).toLowerCase()}.addr.reverse`;
  const node = namehash(reverseName);
  const resolver = rns.resolver(node);
  const name = resolver.name(node);
  return name;
}

function getName(address) {
  const reverseDomain = `${address.slice(2).toLowerCase()}.addr.reverse`;
  const node = namehash(reverseDomain)
  const resolver = rns.resolver(node)
  if (!resolver.supportsInterface('0x691f3431'))
    throw;
  return resolver.name(node);
}

Receive updates

Get the latest updates from the Rootstock ecosystem

Loading...