Skip to content
Lattice

IENSResolver

Git Source

Title: IENSResolver

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ENS (https://github.com/ensdomains/ens-contracts), Conforms to ENS forward resolution (EIP-137)

External interface for the ENS forward-resolution facet: lets a diamond look up ENS names -> addresses on-chain via the configured ENS registry.

Read-only resolution plus a configurable registry (gated on ENS_MANAGER_ROLE). Basic resolution only (registry -> resolver -> addr); ENSIP-10 wildcard / extended resolution is out of scope for v1.

Functions

resolve

Resolves an ENS node to its address (forward resolution).

Reads registry.resolver(node) then resolver.addr(node). Returns zero ONLY when node has no resolver configured; MAY revert if a configured resolver does not implement addr(bytes32) or itself reverts. The resolved address is set by the node's owner (a third party), so treat it as untrusted; use resolverOf to distinguish "no resolver" from "zero".

function resolve(bytes32 node) external view returns (address);

Parameters

NameTypeDescription
nodebytes32The ENS node (namehash) to resolve.

Returns

NameTypeDescription
<none>addressThe resolved address (zero if no resolver is set).

resolverOf

Returns the resolver configured for node in the ENS registry.

function resolverOf(bytes32 node) external view returns (address);

Parameters

NameTypeDescription
nodebytes32The ENS node (namehash) to query.

Returns

NameTypeDescription
<none>addressThe resolver address (zero if unset).

ensRegistry

Returns the configured ENS registry.

function ensRegistry() external view returns (address);

Returns

NameTypeDescription
<none>address

setEnsRegistry

Sets or rotates the ENS registry (per-chain configuration).

Gated on ENS_MANAGER_ROLE. Reverts ENSResolverZeroRegistry for a zero address.

function setEnsRegistry(address ensRegistry) external;

Parameters

NameTypeDescription
ensRegistryaddressThe ENS registry to use.

subnode

Computes the namehash of label.<parent> from the parent node and label.

One ENS namehash recursion step: keccak256(parentNode ++ keccak256(label)).

function subnode(bytes32 parentNode, string calldata label) external pure returns (bytes32);

Parameters

NameTypeDescription
parentNodebytes32The parent name's node.
labelstringThe subname label.

Returns

NameTypeDescription
<none>bytes32The child node (namehash).

Events

EnsRegistrySet

Emitted when the configured ENS registry is set or rotated.

event EnsRegistrySet(address indexed ensRegistry);

Parameters

NameTypeDescription
ensRegistryaddressThe ENS registry address now in use.

Errors

ENSResolverZeroRegistry

Thrown when a zero address is supplied as the ENS registry.

error ENSResolverZeroRegistry();