Skip to content

Tech Talk: Ethereum Naming Service (ENS)

Ethereum Naming Service (ENS) is one of the major innovations to come from the Ethereum network, that makes it easier for users to interact securely and seamlessly on the blockchain. It is also a service that can be utilized on Luniverse, allowing builders to easily deploy ENS contracts via a Luniverse Sidechain.

This post will cover the following topics:

  • What is ENS and why is it useful?
  • How is ENS structured?
  • How does ENS work?
  • How to deploy ENS on a private network with Luniverse.

Keep reading to learn more, or head straight to the Luniverse Console to check out our Web3 infrastructure tools for yourself!

1. What is ENS?


 

In order to understand ENS, first we have to tackle the concept of Domain Name System (DNS).

DNS is a system that translates human-readable domain names into the IP address of a web server. In the early days of the web, users would have to remember or write down the IP address of each website in order to access it, which was extremely inconvenient. However, after the introduction of DNS, it became much easier to access and use the internet. For example, in the past, if you wanted to visit Google, you had to type 142.250.199.110 into the address bar. However, now thanks to DNS, you can simply enter the domain name google.com instead of the IP address.

Similarly, ENS is a service that issues DNS on the Ethereum network. For example, the domain name “luniverse.eth” can be converted to an Ethereum address such as “0x1234567890abcdef”. This allows users to easily send and receive cryptocurrency by inputting an ENS domain name instead of a long and difficult Ethereum address. In 2021, the use of ENS was expanded even further than just the Ethereum network, as over 1300 top-level domain names (such as .com, .org, .io) were able to be integrated with ENS.

2. Features of ENS


 

2-1. Simplification

Since ENS is a much simpler method than writing the complex 42-character address when sending cryptocurrency, it reduces the chance of errors and facilitates safer transactions.

Instead of sharing a long and complex Ethereum address, users can share simple, human-readable domain names. This way, users can easily process transactions and interact with decentralized applications (dApps).

2-2. Safety

ENS provides a decentralized method of linking a domain name to an Ethereum address, which helps protect users from phishing and other malicious activities.

When a user enters a domain name into their wallet or browser, the ENS Smart Contract verifies that the domain name is correctly linked to the Ethereum address. This process helps prevent users from being directed to phishing websites.

Also, public figures or companies can register domain names under their own name, which can aid with promotional activities, since they can use it as an official, recognizable wallet – take vitalik.eth as an example.

https://twitter.com/VitalikButerin

However, it is important to be aware that the person who acquired the domain first becomes the owner, so there is a risk of abuse.

2-3. Regular Renewal Required

Typically, the cost of registering a domain name varies depending on the length of the address. The current costs listed on the official website are as follows:

  • 5+ character .eth names : $5 in ETH per year.
  • 4 character .eth names : $160 in ETH per year.
  • 3 character .eth names : $640 in ETH per year.

After the period expires, a 90-day grace period is given during which the domain can be re-registered, and during this period, record modification is not possible.

2-4. NFT Functionality (ERC-721 Standard)

When you purchase an ENS domain, you are able to own the domain name as an NFT (non-fungible token) which is compliant with the ERC-721 standard. This means that the Domain Registrant is the owner of the ‘.eth’ domain name, and they can transfer ownership to another account through secondary sales. Additionally, domain names created as NFTs can be stored on IPFS (InterPlanetary File System).

2-5. Hierarchical System

Similarly to DNS, domain owners can control subdomains. For example, the domain “luniverse.eth” can create subdomains such as “one.luniverse.eth” and “two.luniverse.eth”.

2-6. Case-Insensitive

Domain names can contain both uppercase and lowercase letters, but after converting to lowercase, the same namehash is generated. For example, the value of namehash(“LUNIVERSE.eth”) and namehash(“luniverse.eth”) are the same.

3. ENS Structure


 

ENS is composed of three main elements.

  • Registry
  • Resolvers
  • Registrars

Let’s take a look at each element one by one! 

https://docs.ens.domains/

3-1. Registry

The ENS registry consists of a single smart contract that maintains a list of all domains and subdomains, and stores information about each of them. Each domain has a structure called a Record, which contains information about the domain, such as the owner, resolver, and ttl (time-to-live). This is shown in the code below.

  • owner: The owner(registrar) of the domain
  • resolver: The resolver for the domain
  • ttl(time-to-live): The caching time-to-live for all records under the domain

Before mapping the domain to a record, it must be hashed with the namehash algorithm.

The owner of each domain has the authority to change information associated with the domain. Through the setSubnodeOwner function, they can create child domains (subdomains) and set the owner of the subdomain. The owner of the subdomain can be different from the owner of the parent domain. If the domain already exists, the ownership will be reassigned but the Resolver address and TTL will not be changed.

The ENS Registry is defined in EIP-137, for more details please refer to this link.

 

3-2. Resolver

The Resolver retrieves the resources mapped to the domain. The resources returned by the query can be a contract address, content hash, or IP address, depending on the interface supported by the Resolver.

There are different versions of Resolvers, depending on what resources they provide. We will look at the Public Resolver, which is defined by various EIPs as shown in the table below.

Because there are different Resolvers, it is necessary to check if the interface you want to use is supported before calling the method. This is done using the supportsInterface function.

The supportsInterface function is defined in ERC-165, and it takes an interface ID as input and returns true or false depending on whether it is supported. The Interface ID is the value calculated by the exclusive-or of the four-byte function identifiers of the functions included in the interface. For example, the interface ID of addr(bytes32) is 0x3b3b57de. Since the Public Resolver supports this function, calling supportsInterface(0x3b3b57de) will return true. Also, since the interface ID of supportsInterface is 0x01ffc9a7, any contract that supports ERC-165 will return true when calling supportsInterface(0x01ffc9a7).

3-3. Registrar

Registrar is the only element that can modify ENS and is responsible for assigning domains to users. The namehash of a domain is called a node, and the owner of the node is called the Registrar. The Registrar can be a contract or an EOA (Externally Owned Account), but if there are subdomains, the Registrar of the top-level domain must be a contract.

Registrar is a contract that owns domains and has rules for subdomain allocation, which can be set by the user. If you write a simple contract with a rule that gives ownership to the first person to register (FIFS, First In First Served), it would look like the code below.

In this way, writing the rules is entirely up to the user.

 

4. How does ENS work?


4-1. Namehash

Before using ENS, you have to go through a process of hashing the domain name. This process uses the namehash algorithm. This algorithm hashes the components that make up the domain name recursively and outputs a hash value, called a node.

For example, if we go through the namehash process for “luniverse.eth”, it will be done as follows.

If you check the hash values for each process, they will be as follows:

namehash('') = 0x0000000000000000000000000000000000000000000000000000000000000000
namehash('eth') = 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae
namehash('luniverse.eth') = 0x8e0af5c371f0b0705d67f189029150cc70189e4746dad8ca2d1d48a9eb8e2e40

So why not just record the domain name directly into ENS? Using namehash provides the following benefits:

  1. Consistency: Namehash provides a consistent and standardized way to convert domain names into a unique hash value, which is necessary for ENS to function properly.
  2. Scalability: Namehash is designed to be highly scalable, which means that it can handle large numbers of domain name registrations and resolutions without any issues.
  3. Efficiency: By using namehash, it allows ENS to work more efficiently with fewer resources, as it reduces the need for lookups and other processes that can slow down the system.

4-2. ENS Process

https://docs.ens.domains/

To load resources through ENS, the following steps must be carried out:

  1. Before calling the Registry, perform namehash for the domain name.
  2. Send a request to the Registry and obtain the address of the Resolver.
  3. Call the method of the Resolver obtained in step 2 to output the desired resource.

For example, let’s say we are trying to load the content hash stored in luniverse.eth.

First, we perform the namehash process for luniverse.eth.

We receive the Resolver address from the Registry.

Then we request the content hash from the Resolver.

5. Conclusion


Since the first appearance of DNS in Web2, it has become a service that all users have become used to over time. Similarly, as Web3 is becoming more visible, the number of domain names registered in ENS is increasing rapidly. The number of companies interested in entering the Web3 market is also increasing. However, it may be difficult to use ENS due to the high gas fees of the Ethereum network. However, if ENS is deployed on a private network, various tests can be conducted without the need for gas fees. By using Luniverse, you can easily create your own network. In addition, since it is compatible with EVM, you can deploy all ENS contracts written in Solidity without modification.

Get started by creating your own Sidechain on the Luniverse console, by choosing from the options indicated above.

The method to deploy ENS in Luniverse Sidechain is as follows:

  1. Make a sidechain to create your own private network using Luniverse Console. (You can click this link for a detailed tutorial about creating your own Sidechain on Luniverse!)
  2. Deploy the ENS contract on the sidechain created in step 1. This can be done easily with the Luniverse console.
  3. Register the domain name in the ENS Registry. This can be done by calling the ‘register‘ function of the ENS contract on Sidechain and sending the transaction.
  4. Use the ‘setAddress‘ function of the ENS contract to set the address of the contract you want to associate with the domain name.
  5. Finally, you can use the domain name registered in ENS to access the contract on your private network.

Share your blockchain-related digital insights with your friends

Facebook
Twitter
LinkedIn

Get more insights

Say Goodbye to Goerli and Hello to Holesky and Sepolia!

Ending Support for Goerli Testnet on Ethereum, Arbitrum, and Optimism Testnets are cost-effective environments for testing services before their deployment on the mainnet. However, as these testnets essentially function as

02 Arbitrum ONE & NOVA – Why Arbitrum is L2 No.1

This series of posts is content created in collaboration with the Aslan Academy research team, ART: Aslan Research Team, affiliated with the blockchain research society Aslan Academy. This series of

Luniverse NOVA X Arbitrum 01 What is Arbitrum & Why ?

This series of posts is produced in collaboration with ART: Aslan Research Team, a research team within the Aslan Academy, a blockchain research organization. As part of Luniverse NOVA’s support

Luniverse NOVA X Polygon – 3. User Analysis

In the previous articles, we discussed a brief explanation of Polygon and explored various solutions. In this article, we will quantify Polygon into numbers to determine its strengths and weaknesses.