Overview
ENS v2 represents a fundamental architectural shift from the flat, monolithic ENS v1 registry to a hierarchical, modular system. This new design enables flexible ownership models, improved gas efficiency, and better cross-chain functionality.Key Paradigm Shift: Instead of one global registry storing all names, ENS v2 uses a tree of independent registry contracts, where each name can have its own registry managing its subdomains.
Core Architecture Principles
Hierarchical Registry Model
ENS v2 organizes registries in a tree structure that mirrors the DNS hierarchy:- Is responsible for one name and its direct subdomains
- Implements the
IRegistryinterface for standard resolution - Can have a custom implementation with different ownership models
- Stores data in the centralized
RegistryDatastorefor gas efficiency
Registry as NFT Container
Every registry implements ERC1155Singleton, treating subdomains as NFT tokens:.eth registry manages all second-level domains like vitalik.eth, nick.eth as individual NFT tokens.
Core Components
1. Registry Contracts
Registries are the fundamental building blocks:Registry Storage Structure
Each name in a registry has an associated entry:PermissionedRegistry.sol:56-62
2. Universal Resolver
TheUniversalResolverV2 provides a single entry point for resolving any ENS name:
- Recursive traversal through the registry hierarchy
- Wildcard resolution support (parent resolvers can handle subdomains)
- CCIP-Read support for off-chain resolution
- Batch resolution capabilities
UniversalResolverV2.sol
3. Enhanced Access Control (EAC)
EAC provides resource-scoped, role-based permissions:Resource-Scoped Permissions
Resource-Scoped Permissions
Unlike traditional role systems, EAC assigns roles to specific resources (individual names) rather than contract-wide:
Paired Admin Roles
Paired Admin Roles
Each regular role has a corresponding admin role that can grant/revoke it:
Root Resource Override
Root Resource Override
The special
ROOT_RESOURCE (value 0) provides contract-wide permissions:EnhancedAccessControl.sol
4. ERC1155Singleton Token Standard
A gas-optimized variant of ERC1155 that enforces one token per ID:- Saves gas by eliminating balance tracking
- Provides familiar
ownerOf()interface like ERC721 - Maintains ERC1155 compatibility for marketplace support
ERC1155Singleton.sol
Data Flow Architecture
Registration Flow
Resolution Flow
Comparison: ENS v1 vs ENS v2
ENS v1
Flat Registry Model
- Single monolithic registry contract
- One ownership model for all names
- Limited extensibility
- Higher gas costs for complex operations
- Name Wrapper required for advanced features
ENS v2
Hierarchical Registry Model
- Independent registry per name
- Custom ownership models per registry
- Highly extensible and composable
- Optimized gas usage
- Advanced features built-in
Key Improvements
| Feature | ENS v1 | ENS v2 |
|---|---|---|
| Architecture | Flat, single registry | Hierarchical, multiple registries |
| Ownership Models | Fixed | Customizable per registry |
| Access Control | Owner-only | 32 granular roles |
| Subdomains | Manual delegation | Automatic via subregistries |
| Gas Efficiency | Moderate | Optimized |
| Token Standard | Name Wrapper (ERC1155) | Native ERC1155Singleton |
| Backward Compatibility | N/A | Full ENS v1 support |
Design Patterns
1. Registry Composition
Registries can be composed to create complex ownership structures:2. Emancipated Names
Create names that the parent cannot interfere with:3. Soulbound Names
Create non-transferable names by revoking transfer permissions:RegistryRolesLib.sol:34
Security Considerations
Admin Role Protection
The registry prevents admin roles from being granted to external accounts:PermissionedRegistry.sol:447-454
Next Steps
Hierarchical Registries
Learn how registries work together in the hierarchy
Canonical ID System
Understand the mutable token ID system
Resolution Process
Discover how name resolution traverses the hierarchy
Registry Roles
Explore the role-based permission system