How ENS Domains Work: Everything You Need to Know
The Ethereum Name Service (ENS) replaces long hexadecimal addresses with human-readable names like alice.eth. Unlike traditional DNS, ENS operates on the Ethereum blockchain, leveraging smart contracts for registration, resolution, and transfer. This article provides a methodical breakdown of how ENS domains function under the hood, covering the registry, registrar, resolver, and the lifecycle of a name. Whether you are integrating ENS into a dApp or managing a portfolio of names, understanding these mechanics is essential.
1. Core Architecture: Registry, Registrar, and Resolver
ENS is built on three layers, each with a distinct role:
- Registry (ENS.sol): A single smart contract deployed on Ethereum mainnet (and testnets). It stores the owner of each domain, the resolver contract address, and the time-to-live (TTL) for caching. The registry is the authoritative source of truth — it does not store the actual mapping to addresses.
- Registrar: A separate smart contract that controls how names are registered, renewed, and released. The current registrar for .eth names uses a Vickrey auction-style mechanism (the "Controller" pattern) with commit-reveal to prevent frontrunning. Registration is performed via the ETHRegistrarController, which handles pricing, duration, and oracle feeds for ETH/USD conversion.
- Resolver: A contract that implements the
IERC165interface and returns records (e.g., ETH address, IPFS content hash, text records). The resolver is the layer where DNS-like functions live — you can point your ENS name to a wallet, a website, or a contract. Popular resolvers include the PublicResolver (default for most .eth names) and custom resolvers for advanced use cases.
When a user types alice.eth into a wallet, the client queries the registry to find resolver address for that name, then calls addr(node) on that resolver to get the ETH address. This two-step lookup allows modular upgrades without touching the registry.
2. Registration Lifecycle: From Commitment to Expiration
Registering a .eth ENS domain follows a strict commit-reveal protocol. This prevents frontrunning where a malicious observer sees your desired name and registers it first. The process breaks down into four precise steps:
- Commit: Generate a secret (random bytes), compute the hash
keccak256(name + owner + secret), and send a transaction to the Registrar Controller with this commit hash. The secret must not be revealed yet. - Wait 1-10 minutes: The EthRegistrarController enforces a minimum commitment age (60 seconds at time of writing, with a maximum of 86400 seconds). This prevents instantaneous frontrunning. No collateral is required at this stage — only gas.
- Reveal: After the wait period, call
register()with the plaintextname,owner,secret, and the registration duration. The controller verifies the commit hash matches, checks name availability, calculates the rent fee in ETH (based on the current oracle price), and mints an ERC721 NFT representing the domain. - Set Resolver and Records: After registration, the owner must call
setResolver()on the registry to point to a resolver (e.g., the PublicResolver), then callsetAddr()on that resolver to assign a target address. Until this is done, the name resolves to null.
The registration fee is linear with duration — a 1-year registration costs the base rent, while 10 years costs 10x. The rent is denominated in USD but paid in ETH via an oracle (Chainlink ETH/USD). If you want to avoid missing renewal windows, consider setting up automatic renewal via a keeper network or using a third-party service. For a full overview of registration conditions and ongoing management, Ens Civic for comprehensive guides and tooling integration details.
3. Subdomain Management and Delegated Ownership
ENS supports hierarchical domains via subnames. The owner of example.eth can create subdomains like pay.example.eth or dev.example.eth. Unlike DNS zone files, ENS subdomains are ERC721 tokens in their own right — they can be owned by separate wallets, transferred, and configured independently. This is achieved through the setSubnodeOwner() function in the registry.
There are two common patterns:
- Direct Ownership: The parent owner calls
setSubnodeOwner(parentNode, label, newOwner)to assign the subdomain to a different address. The new owner then controls registration and records for that subdomain. - Delegated Registration (Resolver-based): A custom resolver can allow third parties to register subdomains under your name programmatically, using a
setSubnodeRecord()that sets owner, resolver, and TTL in one transaction. This pattern is used by ENS subdomain registrars and DAO-controlled names.
This structure makes ENS ideal for decentralized identity (DID) systems, where each user gets a subdomain under a project's namespace. The parent retains zero control over subdomains it has relinquished, aligning with Web3's permissionless ethos.
4. Renewal, Expiration, and Grace Periods
ENS .eth names are not permanently owned — they are leased. The maximum registration duration is capped (currently 100 years). Once the lease expires, the name enters a multi-phase lifecycle:
- Grace Period (90 days): After expiration, the owner can still renew. No one else can claim the name. The name remains resolvable during this period. Renewal costs the full rent for the new duration (no discount).
- Premium Period (21 days): After the grace period, the name becomes "available for premium". Anyone can start a claim via a Dutch auction — the price starts high and decays linearly each day until it reaches the base rent. The premium decrements by a fixed percentage (e.g., 50% per day) until reaching 0 after 3 weeks.
- Final Release: Once the premium period ends, the name becomes available for registration at standard rent (first-come, first-served). No commit-reveal is required — you can register directly.
It is critical to monitor expiration dates. ENS sends email reminders if you set them in the manager, but relying on on-chain monitoring is safer. Use a multi-sig or automated keeper to renew high-value names. If you need to plan your submission timeline carefully, check the ENS registration event calendar for upcoming availability windows and premium phase transitions.
5. Integration Considerations for Developers
For technical teams building on ENS, three integration points deserve attention:
- Library Support: Use
ethers.jsorweb3.jswith the@ensdomains/ensjspackage. It abstracts the registry, resolver, and registrar calls. TheENS.resolveName()method handles the two-step lookup (registry → resolver) automatically. For reverse resolution (address → name), useENS.lookupAddress(). - Gas Considerations: The commit-reveal process costs approximately 60k-80k gas for commit + 150k-200k gas for reveal (depending on duration). Setting records costs 30k-50k. Use a gas estimator and batch transactions where possible. For high-frequency operations, consider using L2 solutions like ENS on Arbitrum or Optimism (via the ENS L2 bridge).
- Resolver Upgrades: Resolvers are immutable unless you deploy a new version. The registry stores the resolver address, so you can upgrade by calling
setResolver()to point to a new contract. However, this breaks any cached records — clients must wait for TTL expiration. Standard TTL is 86400 seconds (1 day).
ENS is fundamentally a relational database spread across two contracts (registry + resolver). The separation of concerns allows lightweight registrations and complex resolver logic without bloating the core contract. For production deployments, always test on Goerli or Sepolia testnets using ENS test fixtures.
Understanding the registry-registrar-resolver triad, the commit-reveal lifecycle, subdomain delegation, and expiration dynamics equips you to use ENS correctly — whether as a user, investor, or developer. The system is deliberately engineered for decentralization: no central party can seize or censor a name, and all actions are auditable on-chain. As ENS gains adoption in wallets (MetaMask, Rainbow), DNS integration (ENS Link), and DeFi naming (e.g., Uniswap subdomains), its importance as an infrastructure layer grows.