Skip to main content

Ethereum Name Service (ENS) Architecture: A Detailed Guide

ENS, standing for Ethereum Name Service, is a fundamental part of the Ethereum ecosystem. It equips the Ethereum blockchain to allocate, manage, and resolve human-friendly names, such as 'yourname.eth', thereby abstracting away the complexity of dealing with hexadecimal addresses for end users. In this guide, we will delve into the precise architecture and inner workings of the ENS protocol.

1. High-Level Architecture

The architecture of ENS is decentralized and systematic, incorporating several main constituents: a registry, registrars, resolvers, and the users or entities that interact with these components.

  • Registry: The Registry is an Ethereum smart contract that maintains a record of all domain names in the ENS system, along with references to corresponding Resolver and owner addresses.
  • Registrar: A Registrar is a smart contract that owns a top-level domain (like yourname.eth) and creates second-level domains (like 'username.yourname.eth'). It has the ability to define the rules and mechanisms for the assignment of these subdomains.
  • Resolver: A Resolver is another type of smart contract that, when presented with a domain name, returns the appropriate address or resource associated with that name.
  • Users: Users are individuals or entities that interact with the ENS protocol, whether by registering a new domain name, updating the resources linked to a domain name, or querying a domain name to fetch its linked resources.

2. A Closer Look at ENS Contracts

ENS operates through a collection of smart contracts, each with distinct responsibilities.

2.1. ENS Registry Contract

The ENS Registry Contract is the backbone of the ENS system. It stores a list of all domain and subdomain names within ENS. Importantly, the ENS Registry doesn't store detailed data like the owner of a domain or associated addresses. Instead, it merely links each domain to its corresponding Resolver contract. The Registry also keeps track of the owner of each domain - any changes to a domain's records or its Resolver can only be conducted by the domain's owner.

2.2. Resolvers

A Resolver is a contract that contains the logic for translating a name into its relevant resources, like an Ethereum address, IPFS hash, or other blockchain addresses. While the ENS system has a standard Public Resolver that can handle various record types and respond to any resource request, each individual domain has the freedom to specify any contract as its Resolver, as long as it adheres to the ENS Resolver interface.

2.3. Registrars

A Registrar is a contract that owns a domain and is in charge of allocating subdomains to users. The rules by which Registrars allocate domains can differ - they can adopt a first-come-first-serve approach or use more complicated mechanisms like auctions or democratic voting.

2.4 ENS Name Wrapper

The Name Wrapper is a recent addition to ENS. It wraps your ENS name into a tokenized format, turning it into a non-fungible token (NFT), specifically to an ERC-1155 token. This contract inserts another level into the resolution process—it’s a contract that owns the name in the registry, and maintains a separate record of who has control of the name.

3 Working Flow of ENS

Here's the typical workflow of an ENS resolution:

  1. A user or application wants to fetch the Ethereum address associated with 'yourname.eth'.
  2. It first queries the ENS Registry Contract to discover the Resolver for 'yourname.eth'.
  3. Once it has the Ethereum address of the Resolver, it calls that Resolver contract and asks for details about 'yourname.eth'.
  4. The Resolver returns the desired Ethereum address.
  5. The user can now interact with the fetched Ethereum address to send funds, interact with contracts, or just save it for future use.

This workflow illustrates the role of each part of the ENS and their integrative functioning: the ENS Registry pointing the user to the right Resolver, the Resolver carrying out the job of resolving the requested name to an address, and the final use of that address by the user or application.

3.1 Working Flow of ENS with Name Wrapper

The ENS with Name Wrapper works as follows:

  1. A user requests to resolve a domain name or register a new domain.
  2. If registering a domain, the user interacts conventionally with the Registrar Controller. Post-registration, they can choose to wrap their name via the Name Wrapper contract.
  3. During wrapping, the name gets transferred to the Name Wrapper Contract while also keeping a record of who controls the name.
  4. In name resolution, if a name is found to be wrapped, requests are then sent to the Name Wrapper contract which returns the information on name resolution.
  5. Inside the Name Wrapper, specific access rights are granted to the controllers to manage various functionalities.
  6. In the unwrapping process, control over the name can be returned directly to the user or any Ethereum address they performed.

4. DNS and ENS Interoperability

ENS has a unique feature where it can interoperate with the traditional Domain Name System (DNS). ENS users can claim .ETH domains, and those domains can be resolved to externally owned accounts (EOAs) or contracts. For DNS owners to create equivalent ENS records, ENS provides a DNSSEC (Domain Name System Security Extensions) oracle that allows DNS owners to claim their DNS domains on ENS. This solidifies the fundamental principle that building bridges between on-chain and off-chain worlds is integral to blockchain's success.