ENS Logo
Docs

Resolution

The process by which we load information about a name is called resolution. It's a simple process, but it's important to understand. Here is a diagram of some of the contracts involved when resolving a name.

The resolution process involves multiple parts. Most notably the Registry, multiple Registrars (ETH Registrar, DNS Registrar, Reverse Registrar, etc) and the concept of a Resolver.

How to resolve

Here is a little peak at what happens under the hood of your favourite library when you do a name lookup.

1. Find the Resolver

Every name has a "resolver". A resolver is simply a contract that implements the resolver specification and can be queried for information about a name. To get the resolver responsible for a name you can query The Registry for the resolver of a name.

Get the resolver
ENS.resolver(bytes32 node) view returns (address)
import { useEnsResolver } from "wagmi";
import { normalize } from 'viem/ens';

export const MyResolver = () => {
    const { data: myResolver } = useEnsResolver({
        name: normalize("luc.eth"), // The name to lookup
    });

    return <div>{myResolver}</div>;
};
const resolver = await provider.getResolver("luc.eth");
import { normalize } from "viem/ens";
import { publicClient } from "./client";

const ensResolver = await publicClient.getEnsResolver({
    name: normalize("luc.eth"),
});

To verify which specifications are implemented by a resolver you can call the supportsInterface(bytes4 interfaceID) on the resolver with the interfaceID you would like to test for.

2. Query the Resolver

Now you have found the resolver responsible for the name in question, you can query it for the information you are interested in. There are many ways you can query the resolver, addr() text() contenthash() abi() etc.

If the resolver supports text records you can call text() to get that text record for the name. More about loading information from a resolver can be found here.

Wildcard Resolution

In addition, all of the above functions can be sent to the resolve() function, specified in ENSIP-10. This allows for not only multicall functionality, but also easier implementation of EIP-3668, and more.

Reverse Resolution

Due to the modular nature of how ENS is designed, it is also possible to lookup the "primary name" of an address. This process actually uses forward resolution under the hood, you read that right - its just forwards resolution.

To look up the primary name of a given address you must do a resolver lookup for addr.reverse and then query the name() field on the resolver. This name field returns the "preferred" name for the address. Note that the implementing client MUST perform a forward resolution on this name to verify the address matches the one you are looking up.

Last Modified
last month