The primary purpose of the Ethereum name service (ENS) is to convert machine-readable identifiers like Ethereum addresses to human-readable names.
The web began as a decentralized system based on the DNS, with anybody able to buy, own and manage their domain name and move it from one host to another as needed, with complete control and ownership over all underlying data. But, how does a decentralized Web3 name service work?
The community has shown a lot of interest in ENS, which is a new name service built on top of Ethereum. The Ethereum Name Service is a Web3 blockchain system that allows users to establish their own unique and memorable usernames.
Therefore, ENS intends to provide a complementary solution to DNS by utilizing Ethereum smart contracts to govern domain name registration and resolution. Using the service, you can provide a single name to all of your wallet addresses and decentralized websites (DWebs). “alex.eth,” for example, makes you recognize and quickly locate wallet addresses in a distributed environment.
The registry, the registrars and the resolvers are three kinds of smart contracts in ENS, as explained in the sections below.
The registry
A single smart contract runs the ENS registry and keeps track of all domains and subdomains. The system purposefully has been kept basic, and its sole purpose is to link a name to the resolver that is accountable for it. It also saves the following three crucial pieces of data:
- The owner of the domain: An external account or a smart contract can be the domain owner. The domain owner can update the domain’s resolver and TTL, transfer the ownership of the domain to another address and alter the right of subdomains.
- Resolver of domain names: The process of converting names into addresses is handled by resolvers. Any contract can become a resolver if it follows specific guidelines.
- ENS Namehash: ENS saves names as hashes, which are produced using the “namehash” method. The namehash is calculated by combining the hash of the highest-level part of ENS domain names (known as “labelhash”) with the namehash of the other parts and then performing another hash on it.
The registrars
A registrar is a smart contract that holds a domain name and can grant subdomain names to users depending on rules (e.g., payment). The ENS team used the Vickrey auction registrar and the permanent registrar for .eth name registrations.
On May 4, 2017, the ENS team released a smart contract implementing a Vickrey auction to register names longer than six characters. The Vickrey auction is a sort of sealed-bid auction in which buyers bid without knowing how many other bidders have bid, and the auction winner is the highest bidder who only has to pay the second-highest amount.
On May 4, 2019, the ENS team introduced the “permanent registrar” in place of the auction registrar for registering names longer than six characters. The perpetual registrar is designed to run indefinitely until the registrar contract is replaced due to a severe flaw. The manner of billing for .eth names has been modified to an annual rent payment model, in which each name will be charged $5 per year.
Along with the permanent registrar, the registrar controller idea was created to allow name owners to delegate name management. As a result, a name registered by the registrar controller can configure resolver and name records as part of the registration transaction, simplifying the procedure.
Another auction called the short name auction for remaining short names with a length of 3–6 commenced in September 2019. The ENS team used OpenSea, a well-known crypto-asset marketplace, as the auction platform, with the English auction as the auction method.
Bids in an English auction are open to the public, and bidders can place numerous bids. The highest bidder will get the name, and the number of deposits will be the first-year registration fee, which is considerably different from the Vickrey auction period.
The resolvers
The name-to-record mapping is saved in the resolver. The “public resolvers” implemented by the ENS team have preset eight categories of records (see image below), but ENS can hold any records.
The ENS name resolving procedure is two-step. First, the user who wishes to resolve the name must search the registry for the relevant resolver and then obtain the resolver’s resolution results.