Overview
The UniversalResolverV2 contract extends the ENS universal resolution system to support multiple registries in the ENS v2 architecture. It provides a unified interface for resolving names across different registry namespaces while maintaining backward compatibility with the ENS v1 resolver interface.UniversalResolverV2 inherits from
AbstractUniversalResolver and uses the LibRegistry library for registry traversal and resolution.Key Features
Multi-Registry Support
Resolve names across multiple connected registries in the hierarchy
Canonical Lookups
Find canonical names for registries and canonical registries for names
Registry Traversal
Walk the entire registry ancestry for any given name
CCIP-Read Compatible
Supports batch gateway providers for off-chain resolution
Contract Address
The contract is deployed with an immutable reference to the root registry:Constructor
The root registry contract address
Gateway provider for CCIP-Read batch operations
Core Resolution
findResolver
Finds the resolver, node, and offset for a given name by traversing the registry hierarchy.DNS-encoded name to resolve
The resolver address, or
address(0) if not foundThe namehash of the resolved portion
Offset into the name where the resolver was found
Example: Finding a Resolver
The resolver returned might be for the exact name or for a parent in the hierarchy. The
offset parameter indicates which portion of the name was actually resolved.Canonical Name Operations
findCanonicalName
Constructs the canonical DNS-encoded name for a given registry address.The registry contract to name
DNS-encoded canonical name, or empty if not canonical
Example: Getting Canonical Name
findCanonicalRegistry
Finds the canonical registry for a given DNS-encoded name.DNS-encoded name to look up
Canonical registry address, or
IRegistry(address(0)) if not canonicalExample: Verifying Canonical Registry
A registry is canonical for a name if:
- The registry exists at that name path
- Walking backwards from the registry produces the same name
Registry Hierarchy Traversal
findRegistries
Finds all registries in the ancestry of a name, from most specific to root.DNS-encoded name to traverse
Array of registries in label-order (most specific to root)
Example: Walking the Registry Tree
Traversal Examples
Here are the results for different name queries:Empty name (root)
Empty name (root)
Top-level domain
Top-level domain
Second-level domain
Second-level domain
Non-existent subdomain
Non-existent subdomain
Resolution Flow
The resolution process follows this hierarchy:Integration Examples
Basic Name Resolution
Multi-Chain Resolution
Registry Verification
Gas Optimization
The UniversalResolverV2 uses several optimization techniques:Security Considerations
View Functions: All resolution functions are
view, meaning they cannot modify state and are safe to call from other contracts or off-chain.Related Contracts
IRegistry
Registry interface
PermissionedResolver
ENS v2 resolver implementation