How ENS registration works on the smart contract layer

Gonzalo Izquierdo Brown
Coinmonks
Published in
3 min readJun 9, 2022

--

When performing an ENS registration from ENS official web app, it resolves to several smart contract calls that actually registers the name in its registry.

The registrar uses two transactions (commit and reveal) to register a name and it takes less than 5 minutes to register a name, including a 1-minute delay between the first and second transactions to prevent frontrunning.

ENS as NFTs

Every registered ENS is also minted as an ERC721 token so .eth names are tradable as NFTs on exchanges.

They can also be transfered to someone else using the ENS app or any tool with NFT support

Registrant and controller

The registrant is the account that owns the .eth name. They can transfer ownership to another account, and they can replace the controller address. The registrant is the owner of the NFT token that represents the name.

The controller is the account that controls day-to-day operations with the name: creating subdomains, setting the resolver and records, and so forth.

Smart contract execution

The first part of ENS registration is calling the ETH Registrar Controller contract and performing a commit transaction. This transaction only pays the network fees and establishes a commitment to register a certain ENS.

After completing the commitment transaction, the app has to manually run the register transaction.

ENS web app does this by calling the function Register with Config from the Registrar Controller. This config is sent as a data parameter with the next fields:

name (string): domain name without ‘.eth’
owner (address): domain owner address
duration (uint256): how long the domain will be registered
secret (bytes32): hashed secret
resolver (address): resolver contract, by default, public resolver

When receiving these parameters correctly, the contract performs the registration with the following steps:

  1. Registers the ENS domain [name].eth for x ETH on ENS
  2. Sets expiration date using the duration provided
  3. Mints ENS as an ERC721 token
  4. Transfers the token to the owner

Completed registration: ENS details

When all the transactions are confirmed, we can see through the ENS app that the ENS [name].eth is registered and shows the following data:

Parent: Every L1 ENS has eth as a parent. This goes for ALL the domain names .eth (not for subdomains).

Registrant: Shows the address of the registrant and owner of the domain. When transfered, this address is updated to the new owner.

Controller: Shows the address of the controller of the domain. See Registrant and controller for more details.

Expiration date: Set from duration when registering the domain.

Resolver: Shows the address of the contract that resolves the name, or in other words, that knows where the ENS points to.

Metadata

Every ENS has the capability to store addional data. The Controller address is the only one authorized to update these values.

ENS metadata is divided in 3 sections:

ADDRESSES: Can store different wallet addresses (for different blockchains). Currently, you can only store an ETH, BTC, LTC and DOGE address.

CONTENT: Meant for general purpuse text field storage.

TEXT RECORD: This section is the most interesting one. It allows the controller to store different text fields in a key value format. At the time, you can store the following fields:

  • avatar
  • email
  • url
  • description
  • notice
  • keywords
  • com.discord
  • com.githug
  • com.reddit
  • com.twitter
  • org.telegram
  • eth.ens.delegate

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also, Read

--

--