Key Features
EAC extends traditional access control with powerful capabilities designed for the hierarchical nature of ENS:Resource-Scoped Permissions
Assign roles to specific names rather than contract-wide, enabling precise delegation of permissions
Paired Admin Roles
Every role has a corresponding admin role that can grant or revoke it, creating a clear permission hierarchy
Root Resource Inheritance
Permissions granted at the root level automatically apply to all resources in the contract
Gas-Efficient Storage
Bitmap-based implementation supports up to 32 roles with minimal storage overhead
Core Concepts
Resources
A resource is any entity that can have permissions assigned to it. In ENS v2 registries:- Each name is a unique resource identified by its canonical ID
- The special resource
0(ROOT_RESOURCE) represents contract-level permissions - Resources are represented as
uint256values, making the system flexible for any use case
Roles
Roles are represented as 4-bit nybbles within auint256 bitmap:
- Regular roles occupy the lower 128 bits (32 roles: bits 0-127)
- Admin roles occupy the upper 128 bits (32 admin roles: bits 128-255)
- For any role at bit position
N, its admin role is at positionN + 128 - Multiple roles can be combined using bitwise OR operations
Role Assignees
Each role can have up to 15 assignees per resource. This limit ensures efficient bitmap-based counting while supporting realistic delegation scenarios.Permission Inheritance
When checking if an address has a role for a specific resource, EAC combines permissions from two sources:- Resource-specific roles: Permissions granted directly for that resource
- Root resource roles: Permissions granted at the ROOT_RESOURCE level
Root-level permissions are powerful. An account with
ROLE_SET_RESOLVER at the root level can set the resolver for any name in the registry.Admin Role Capabilities
Granting Roles
To grant a role to another account, you must hold the admin role for that role:- Holding
ROLE_SET_RESOLVER_ADMINallows grantingROLE_SET_RESOLVER - Admin roles can be granted at the root level or for specific resources
- Admin roles can grant themselves (admin roles can grant admin roles)
Revoking Roles
Revocation follows the same pattern:- Hold the admin role to revoke the corresponding regular role
- Admin roles can be revoked from yourself (useful for creating soulbound tokens)
- In registries, only the name owner can hold admin roles
Comparison with OpenZeppelin
While OpenZeppelin’s AccessControl provides contract-wide roles, ENS v2’s EAC adds:| Feature | OpenZeppelin | ENS v2 EAC |
|---|---|---|
| Scope | Contract-wide | Per-resource |
| Admin structure | Multi-level | Paired (1:1) |
| Inheritance | Via role hierarchy | Via ROOT_RESOURCE |
| Max roles | Unlimited | 32 roles + 32 admin roles |
| Storage | Hash-based | Bitmap-based |
| Gas efficiency | Moderate | Optimized |
Use Cases
Delegate Resolver Management
Grant an operator permission to update resolvers without giving them transfer rights:Global Registry Administrator
Grant contract-wide permissions for a trusted administrator:Emancipated Subnames
Create names that parent owners cannot interfere with:- Create a subregistry with no root roles for the owner
- Lock the subregistry into the parent registry
- Result: Parent cannot modify subname operations
Security Considerations
Next Steps
Enhanced Access Control
Deep dive into the EAC implementation and technical details
Registry Roles
Learn about the specific roles used in registry contracts
Permission Inheritance
Understand how permissions flow from root to resources
API Reference
Complete API documentation for EnhancedAccessControl