Introduction
The ENS v2 registry system is a fundamental redesign that transforms domain names into tradeable ERC-1155 tokens with fine-grained access control. Each registry manages subdomains as individual tokens with customizable permissions, enabling sophisticated delegation and governance patterns.Core Architecture
The registry system consists of four primary contracts:PermissionedRegistry
Base contract implementing role-based access control for domain management
UserRegistry
Upgradeable registry for user-created subregistries
WrapperRegistry
Migration-enabled registry for locked ENS v1 names
Registry Datastore
Singleton storage pattern using ERC-1155 for efficient token management
Key Concepts
Name Lifecycle States
Each subdomain in a registry exists in one of three states:Available
The default state for any unregistered label. Anyone with
ROLE_REGISTRAR on the parent registry can register it.Reserved
A transitional state where a label has an expiry but no owner. Useful for name auctions or grace periods. Only accounts with
ROLE_REGISTER_RESERVED can complete the registration.Versioned Identifiers
The registry uses three types of identifiers that can be used interchangeably in most functions:Label ID (Storage ID)
Label ID (Storage ID)
The
keccak256 hash of the label without version information. Used as the storage key.Token ID
Token ID
Label ID combined with
tokenVersionId to create a unique ERC-1155 token ID. The version increments when roles change or tokens are regenerated.Resource ID
Resource ID
Label ID combined with
eacVersionId for access control. The version increments when the name is unregistered or expires.Most registry functions accept
anyId parameters, which can be any of these three identifier types. The contract automatically extracts the label ID and constructs the appropriate versioned identifier.Registration Flow
The registration process varies depending on the current state of the name:Registering an Available Name
RequiresROLE_REGISTRAR on the parent registry:
Creating a Reservation
Passaddress(0) as the owner to reserve a name without minting a token:
Completing a Reserved Registration
RequiresROLE_REGISTER_RESERVED on the parent registry:
Entry Storage Structure
Each registered name is stored as anEntry struct:
Storage Efficiency: By using version IDs instead of full-size counters and packing all fields into a single storage slot, the registry minimizes gas costs for common operations.
Token Regeneration
When roles are granted or revoked on a registered name, the ERC-1155 token is “regenerated”:- The old token is burned
tokenVersionIdis incremented- A new token with the updated ID is minted to the same owner
Subregistries
Each registered name can optionally have a subregistry - another registry contract that manages its subdomains:Parent References
Registries maintain a canonical reference to their parent:- Upward traversal during name resolution
- Discovery of the full domain path
- Migration path validation
Expiry and Renewal
All registered and reserved names have an expiry timestamp:Expired names remain in storage but return
address(0) for ownerOf() and AVAILABLE status. They can be re-registered without requiring ROLE_REGISTER_RESERVED.State Queries
The registry provides comprehensive state inspection:Events
The registry emits comprehensive events for indexing:Next Steps
PermissionedRegistry
Deep dive into the base registry implementation
Registry Roles
Learn about the role-based permission system
UserRegistry
Explore upgradeable user-deployed registries
Resolution
Understand how names resolve to addresses