Forward Resolution

You can integrate BNS into your project by following this two step resolution process:

  1. Find the resolver: Every resolution process starts by querying the BNS registry to get the resolver address for the name.

   BNS.resolver(bytes32 node) view returns (address)

where node is the namehash (as specified in EIP 137#namehash-algorithm) of the domain name.

  1. Query the resolver: Use the resolver to lookup the resource records associated with the name.

   resolver.addr(bytes32 node) view returns (address)

Universal Resolver

As you have seen above, the resolver is the one responsible for resolving the domain name to the desired data. The resolution though is a two step process, and as such, you can use the universal resolver to resolve the domain name to its address in a single rpc call. This is also the way most of the client libraries expect that a resolution should be done.

   universalResolver.resolve(bytes calldata name, bytes calldata data) external view returns (bytes)

where:

  • name is the dnsEncoded name to resolve.

  • data is the ABI-encoded call data for the resolution function required - for example, the ABI encoding of addr(namehash(name)) when resolving the addr record.

Last updated