Resolvers Quickstart
At the heart of every ENS name is its resolver. A resolver is a smart contract that implements a specific set of Resolver features (see Resolver Interface). The resolvers smart contract functions have control over the resolution process of a "node" (a name or subdomain) and onwards (subdomains of itself).
A naive but very plausible example of a resolver is the following.
contract MyResolver {
function addr(bytes32 node) external pure returns (address) {
return 0x225f137127d9067788314bc7fcc1f36746a3c3B5;
}
function supportsInterface(
bytes4 interfaceID
) external pure returns (bool) {
return
interfaceID == this.addr.selector ||
interfaceID == this.supportsInterface.selector;
}
}
Notice how the above would always return the same address regardless of the name it is queried for.
If you want to write your own resolver resolver, or see the interface reference.
The default resolver for all names is the Public Resolver, a swiss army knife of resolvers, written by the ENS Labs team, feature-packed with everything your everyday user might need. You can read more about the Public Resolver.
Depending on the resolver in charge of a name, certain frontend apps will be able to interact with them as well. This means you can set your favourite records, upgrade your name to different logic, and more, from your dApp of choice.
Are you writing a dApp and want to build this? Checkout the Interacting with a Resolver section.
Although by default ENS resolution is done on-chain. You can leverage the power of CCIP Read to redirect resolution to an off-chain gateway. More about writing a CCIP Read-enabled resolver here.