ens
Installation
SKILL.md
ENS (Ethereum Name Service)
ENS maps human-readable names (alice.eth) to Ethereum addresses, content hashes, and arbitrary metadata. It is the identity layer for Ethereum — used for wallets, dApps, and onchain profiles. The architecture separates the registry (who owns a name) from resolvers (what data a name points to).
What You Probably Got Wrong
- ENS uses
namehash, not plain strings -- The registry and resolvers never see "alice.eth" as a string. Names are normalized (UTS-46), then hashed with the recursivenamehashalgorithm (EIP-137). If you pass a raw string to a contract call, it will not work. viem handles this automatically in its ENS actions but you must usenamehash()andlabelhash()for direct contract calls. - Registry vs Resolver vs Registrar -- three different contracts -- The Registry tracks name ownership and which resolver to use. The Resolver stores records (address, text, contenthash). The Registrar handles
.ethname registration and renewal. Confusing these is the most common ENS integration bug. .ethregistrar uses commit-reveal, not a single transaction -- Registration requires two transactions separated by at least 60 seconds: firstcommit(secret), wait, thenregister(name, owner, duration, secret, ...). This prevents frontrunning. Skipping the wait or reusing a secret will revert.- Reverse resolution is opt-in -- An address only has a "primary name" if the owner explicitly set it via the Reverse Registrar. Do not assume every address has a reverse record. Always handle
nullreturns fromgetEnsName(). - Name Wrapper changes ownership semantics -- Since 2023, ENS names can be "wrapped" as ERC-1155 tokens via the Name Wrapper contract. Wrapped names have fuses that permanently restrict operations (cannot unwrap, cannot set resolver, etc.). Check
isWrappedbefore assuming standard ownership patterns. - CCIP-Read (ERC-3668) enables offchain resolution -- Resolvers can return an
OffchainLookuperror that instructs the client to fetch data from an offchain gateway and verify it onchain. This powers offchain subdomains, L2 resolution, and gasless record updates. viem handles CCIP-Read automatically. - Wildcard resolution (ENSIP-10) is real -- Resolvers can implement
resolve(bytes name, bytes data)to handle any subdomain dynamically, even ones not explicitly registered. This is how services like cb.id and lens.xyz work. - ENS names expire --
.ethnames require annual renewal. Expired names enter a 90-day grace period, then a 21-day premium auction, then become available. Do not cache resolution results indefinitely. normalize()before any ENS operation -- Names must be UTS-46 normalized before hashing. "Alice.ETH" and "alice.eth" produce different hashes. viem normalizes automatically, but if you build raw calldata you must normalize first using@adraffy/ens-normalize.