Skip to content
Lattice

ENSResolver

Git Source

Inherits: IENSResolver

Title: ENSResolver

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)

Stateless Diamond facet for on-chain ENS forward resolution: resolves an ENS node to its address via the configured ENS registry.

All logic lives in ENSResolverLib. The ENS registry is supplied at init and rotated per chain via setEnsRegistry (gated on ENS_MANAGER_ROLE, managed through the diamond's AccessControl).

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Lattice original

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 virtual 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 virtual 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 virtual 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 virtual;

Parameters

NameTypeDescription
ensRegistry_addressThe 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 virtual returns (bytes32);

Parameters

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

Returns

NameTypeDescription
<none>bytes32The child node (namehash).

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect ENSResolver methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: ensRegistry() 0x7d73b231 resolve(bytes32) 0x5c23bdf5 resolverOf(bytes32) 0xc677966d setEnsRegistry(address) 0xe7c65687 subnode(bytes32,string) 0x568f0953

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes