Welcome to ENS v2 Contracts
ENS v2 is a next-generation naming system for Ethereum designed for scalability, flexibility, and cross-chain functionality. It transitions from a flat registry to a hierarchical system that enables custom ownership models while maintaining backward compatibility with ENS v1.What is ENS v2?
ENS v2 is a complete redesign of the Ethereum Name Service that introduces a hierarchical registry architecture where each name can have its own registry contract managing its subdomains. This enables unprecedented flexibility in ownership models, access control, and gas efficiency.Hierarchical Registries
Each name manages its own subdomains through dedicated registry contracts, enabling custom ownership models per level.
Role-Based Access
32 resource-scoped roles with paired admin roles for fine-grained permission management.
Canonical ID System
Mutable token IDs with internal canonical IDs enable secure role management and marketplace protection.
Universal Resolution
Single resolver entry point with wildcard resolution, batch queries, and CCIP-Read support.
Key Features
Hierarchical Registry System
ENS v2 uses a tree of registries where each registry is responsible for one name and its direct subdomains:RegistryDatastore for efficient storage access.
Role-Based Access Control with 32 Roles
ENS v2 uses EnhancedAccessControl (EAC), a gas-efficient access control system with two key features:- Resource-scoped permissions: Roles are assigned to specific resources (individual names) rather than contract-wide
- Paired admin roles: Each base role has exactly one corresponding admin role
Canonical ID System for Mutable Token IDs
Token IDs are regenerated when:- An expired name is re-registered (resets roles for new owner)
- Roles on a name are changed (prevents NFT marketplace griefing)
- Checking role-based permissions
- Reading/writing storage data (expiry, registry, resolver)
Universal Resolver with Wildcard Resolution
TheUniversalResolverV2 provides a single entry point for all name resolution:
- Recursive registry traversal
- Wildcard resolution (parent resolver handles subdomains)
- Batch resolution for multiple names
- CCIP-Read support for off-chain resolution
ENSv1 to ENSv2 Migration Framework
Seamless migration path from ENS v1 with two controllers:LockedMigrationController handles ENS v1 locked names (from NameWrapper)UnlockedMigrationController handles ENS v1 unlocked names (from BaseRegistrar)
Gas-Optimized ERC1155 Singleton
ERC1155Singleton is a modified ERC1155 allowing only one token per ID:
- Saves gas by omitting balance tracking
- Provides
ownerOf(uint256 id)like ERC721 - Emits transfer events for indexing
- All registries share singleton storage pattern
DNS Integration with DNSSEC Support
ENS v2 includes comprehensive DNS support:DNSTLDResolverfor DNS TLD resolution with DNSSEC verificationDNSTXTResolverfor reading TXT recordsDNSAliasResolverfor DNS aliasing- Full DNSSEC validation chain
Architecture Overview
Resolution Process
- Start at root registry
- Recursively traverse to find the deepest registry with a resolver set
- Query that resolver for the requested record
- Support wildcard resolution (parent resolver handles subdomains)
Storage Structure
All registries store data in the singletonRegistryDatastore:
Get Started
Quickstart
Get up and running with ENS v2 in minutes
Installation
Set up your development environment
Core Concepts
Understand the architecture and design
Resources
GitHub Repository
View the source code and contribute
ENSv2 Design Doc
Read the comprehensive architectural design
Contract Interfaces
Key contracts and their roles:| Contract | Purpose |
|---|---|
PermissionedRegistry | Feature-complete registry with role-based access control |
UniversalResolverV2 | Single entry point for all name resolution |
ETHRegistrar | Handles .eth name registration with pricing and commitments |
PermissionedResolver | Resolver with fine-grained permissions and aliasing |
RegistryDatastore | Universal storage contract for all registries |
ERC1155Singleton | Gas-optimized NFT implementation for subdomains |