Registry vs Resolver

This guide explains the fundamental components of the Ethereum Name Service (ENS) architecture: the Registry and Resolver contracts, and how they work together to provide decentralized naming.

ENS Architecture Overview

ENS consists of two main smart contract components:

  1. Registry: The core contract that manages domain ownership and subdomain delegation

  2. Resolver: Contracts that translate names into addresses and other data

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   ENS Registry  │───▶│   Resolver      │───▶│   Target Data   │
│                 │    │                 │    │                 │
│ - Domain Owner  │    │ - ETH Address   │    │ - IPFS Hash     │
│ - Resolver      │    │ - IPFS Hash     │    │ - Website URL   │
│ - TTL           │    │ - TXT Records   │    │ - Email         │
└─────────────────┘    └─────────────────┘    └─────────────────┘

The ENS Registry

The Registry is the core contract that maintains the mapping between domain names and their owners, resolvers, and TTL values.

Registry Functions

interface ENSRegistry {
    // Core domain management
    function setOwner(bytes32 node, address owner) external;
    function setResolver(bytes32 node, address resolver) external;
    function setTTL(bytes32 node, uint64 ttl) external;
    
    // Subdomain management
    function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external;
    function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external;
    
    // Query functions
    function owner(bytes32 node) external view returns (address);
    function resolver(bytes32 node) external view returns (address);
    function ttl(bytes32 node) external view returns (uint64);
}

Registry Data Structure

Registry Operations

1. Domain Registration

2. Setting a Resolver

3. Transferring Ownership

The Resolver

Resolvers are contracts that implement the actual resolution logic, translating domain names into addresses, content hashes, and other data.

Standard Resolver Interface

Public Resolver Implementation

The Public Resolver is the most commonly used resolver implementation:

Registry vs Resolver: Key Differences

Aspect
Registry
Resolver

Purpose

Domain ownership and delegation

Data resolution and storage

Data Stored

Owner, resolver address, TTL

Addresses, content hashes, text records

Update Frequency

Rare (ownership changes)

Frequent (content updates)

Gas Costs

High (ownership operations)

Low (data updates)

Authorization

Domain owner only

Domain owner or authorized accounts

How They Work Together

Resolution Process

  1. Name to Node: Convert domain name to node hash

  2. Registry Lookup: Query registry for resolver address

  3. Resolver Query: Query resolver for specific data

  4. Return Data: Return resolved data to caller

Example: Setting Up a dWebsite

Advanced Resolver Patterns

1. Custom Resolvers

2. Multi-Signature Resolvers

3. Time-Based Resolvers

Gas Optimization Strategies

1. Batch Operations

2. Proxy Resolvers

Security Considerations

Registry Security

  • Ownership Management: Secure domain ownership transfer

  • Access Control: Restrict registry operations to authorized accounts

  • Emergency Procedures: Implement emergency pause functionality

Resolver Security

  • Authorization: Proper access control for resolver updates

  • Input Validation: Validate all inputs to prevent attacks

  • Upgradeability: Consider upgradeable resolver patterns

Monitoring and Analytics

Registry Events

Resolver Events

Best Practices

1. Registry Management

  • Use a dedicated wallet for registry operations

  • Implement proper backup and recovery procedures

  • Monitor for unauthorized ownership changes

2. Resolver Configuration

  • Choose appropriate resolver based on use case

  • Implement proper access controls

  • Consider gas costs for frequent updates

3. Testing

Tools and Resources

Development Tools

Documentation

Next Steps

With a solid understanding of Registry vs Resolver, explore:

Last updated