Written by: MVP Workshop

Ethereum Name Service (ENS) — Bid Farewell to Long Ethereum Addresses


blue blog cover

Ethereum Name Service (ENS) works pretty much like the Domain Name System (DNS). It shortens a confusing string of numbers and characters into a meaningful word or phrase to facilitate transaction processes, and smooth things out among Ethereum users. At the moment, sending an Ethereum address looks something like this:

record types in ethereum

We can all agree that it’s impractical and even a bit annoying to work with these random, algorithmically, generated addresses on a daily basis. Wouldn’t it be nice if we were able to send an address that’s easy to remember and convey meaningful information? Imagine sending an address that looks like this: kristian.mywallet.eth. Makes much more sense, doesn’t it?

In order to solve this burning issue and make the lives of Ethereum users easier, a dapp called the Ethereum Name Service was created. ENS is a decentralized service and obtaining your Ethereum name is a process that differs from buying a domain name.

Moreover, the main difference between ENS and DNS is that DNS is used exclusively for naming IP addresses of websites. On the other hand, you can use the Ethereum Name Service for a couple of things including a personal wallet and your main wallet.

First of all, let’s recap what DNS is and how it solved a problem with IPs more than four decades ago.

A Short History of DNS

Back in the 60s, visiting websites was similar to sharing Ethereum addresses nowadays, as people used directory consisted of IPs instead of domain names.

dns list

If DNS hadn’t been invented back in the day, we wouldn’t have been able to use google.com in order to reach the most popular search engine in the world. Instead, we would have to type in a group of numbers separated by periods. You’ll admit it — you would not enjoy typing 216.58.214.238 to visit Google every time!

Luckily, the problem was solved back in the ARPANET period, and Elizabeth Feinler was the one who initially came up with the idea to replace IPs with actual names, creating the first system which manually connected names to IPs.

With the expansion of the Internet, the DNS became standardized so much that average web users are not even aware that they are actually dealing with IPs.

That being said, a similar problem arose a couple of years ago with the invention of the blockchain technology.

How to Register an Ethereum Name?

What does registering a domain name for a site looks like?

  • We check whether the domain name is free
  • We go to a platform that sells domains
  • We buy the domain

In other words, there is a central authority which is responsible for selling domains, and you can make a purchase via their site. Alternatively, you can purchase owned domains directly from the domain owner. But what happens when there is no central authority which would regulate how Ethereum names are traded?

The answer to this problem is quite straightforward — auction. Those who want to acquire an Ethereum name must place a bid, and the one with the highest bid will become the owner of the requested domain name.

However, things are a bit more complicated than that as the auction process is regulated by smart contracts. These seven steps below show what one auction process looks like.

  1. Check domain status
  2. Start auction (if not already start)
  3. Create a sealed bid
  4. Place the bid
  5. Wait for the revelation phase
  6. Reveal the bid
  7. Finalize auction

Check Domain Status

NOTE: For the purpose of this document ensutil.js script will be used to demonstrate the flow. However, it should not be used in production-ready applications.

First of all, you can check out the availability of a domain name by using the command below.

ethRegistrar.entries(web3.sha3(‘name’))[0];

Once you enter the name of the domain that you want to acquire, you will be able to see its current status. In return, you will receive one of the following responses:

  • 0 — Name is available and the auction hasn’t started
  • 1 — Name is available and the auction has been started
  • 2 — Name is taken and currently owned by someone
  • 3 — Name is forbidden
  • 4 — Name is currently in the ‘reveal’ stage of the auction
  • 5 — Name is not yet available due to the ‘soft launch’ of names.

Let’s go through each of these.

0&1 — If you receive one of the first two responses, you will be allowed to proceed to the next stage of the process. You can either start the auction (0) or join it in its early stage (1).

2 — Names that are taken are not available for auction, but you can always buy them from the current owner.

3 — Some names are simply not available and are forbidden by smart contracts. The contracts have some rules which will not allow users to choose any name they want. I.E. smart contract logic will prevent you from using some special characters such as underscore, thus facilitating more readable naming standard.

4&5 — These two are pretty self-explanatory, and you only need to know that you will not be able to proceed with the auction if you receive either of these responses.

If you fail to join the auction process and start bidding, you should try searching for another name that is either available or the bidding is currently underway.

Start the Auction Process

ethRegistrar.startAuction (
 web3.sha3(‘name’),
 {from: eth.accounts[0], gas: 100000}
);

If there is no ongoing auction, you can pass the name and start the auction process as displayed above.

Generate a Sealed Bid

var bid = ethRegistrar.shaBid (
 web3.sha3(‘name’),
 eth.accounts[0],
 web3.toWei(1, ‘ether’),
 web3.sha3(‘secret’)
);

Creating and sealing a bid is the core process that you should pay the most attention to.

web3.sha3(‘name’),

First of all, you have to pass the hashed name that you want to acquire as your Ethereum domain name.

eth.accounts[0],

Furthermore, you must pass the account that you are bidding from, which will become the account that owns the domain if you manage to win the auction.

web3.toWei(1, ‘ether’),

This is the maximum amount of Ethers that you are willing to pay for the domain name.

web3.sha3(‘secret’)

Finally, this line of code requires you to input a secret phrase that you should remember in order to successfully complete the auction process. If you lose your secret phrase, you will not be able to claim your domain name even if you won the auction.

Place the Bid

ethRegistrar.newBid (
 bid,
 {from: eth.accounts[0], value: web3.toWei(2, ‘ether’), gas: 500000}
);

The next phase is to place the bid.

{from: eth.accounts[0], value: web3.toWei(2, ‘ether’), gas: 500000}

The account which you use for the bidding process and the one you use to seal the bid must be identical, otherwise, you would not be able to claim the domain name.

value: web3.toWei(2, ‘ether’)

The piece of code above is pretty interesting because it states that you are bidding two Ethers although you had indicated that one Ether is the maximum amount you are willing to pay for the domain.

That is a great way to hide your true intentions considering the maximum amount you want to pay, and trick other bidders into thinking that you are paying a lot more. Although everyone is probably aware of this feature, it adds the layer of suspense and, if you play your cards right, you could discourage other bidders from continuing with the auction.

The amount you enter here cannot be smaller than the amount that you had stated as the maximum price in the previous step.

Reveal the Bid

ethRegistrar.unsealBid (
 web3.sha3(‘name’),
 web3.toWei(1, ‘ether’),
 web3.sha3(‘secret’),
 {from: eth.accounts[0], gas: 500000}
);

Once everyone places the bids, a 48-hour-long revelation phase is in order which is a time when the bids are unsealed, and the winner is proclaimed. The one who offered the most Ethers for the domain will become an owner of the domain name.

Two pieces of information are disclosed at this point:

  • The highest bidder
  • The amount they bid

But what happens with those who failed to win? All of them will get a refund after they state the secret phrase and reveal their bid. This is actually a part of the bidding process where you need to remember your secret phrase or your bid will not be refunded.

Finalize the Auction Process

ethRegistrar.finalizeAuction (
 web3.sha3(‘name’),
 {from: eth.accounts[0], gas: 500000}
);

The final part of the auction process is reserved for claiming the Etherum domain name. However, the winner doesn’t get to pay the whole amount that they had bid, as the difference between their bid and the second highest one is refunded to them.

The smart contract is programmed to consider the second highest bid as the actual price of the domain. For example, if you bet 1 ETH for a specific domain name, and the second highest one is 0.7 ETH, you will get 0.3 ETH in return. In other words, the domain’s true value is 0.7 ETH, according to the smart contract.

But what happens if you are the only bidder? If there’s nobody else bidding for the domain name at the moment, there will be no auctions, and you will have an opportunity to buy your domain name for 0.01 ETH.

ENS Architecture

The ENS architecture is rather straightforward. It is divided into two main parts:

  1. ENS Registry — functions as the main smart contract which keeps all the registered Ethereum domain names
  2. Resolver — a smart contract that translates names into addresses
ens registry

You may notice that the top level domain is .eth that works just like .com or .net.

Furthermore, the registry contains several other things:

  1. Owner — this is either a smart contract or an external account
  2. Resolver — either general-purpose resolver or a custom one implemented by the user
  3. Time-to-live — the amount of time that your domain name is valid

The general resolver of the ENS architecture, on the other hand, is there to map names to 0x.

Setting the Resolver and the Address

ens.setResolver(
 namehash(‘somename.eth’),
 publicResolver.address,
 {from: eth.accounts[0]}
);
publicResolver.setAddr(
 namehash(‘somename.eth’),
 eth.accounts[0],
 {from: eth.accounts[0]}
);

After winning the auction, there are a couple of steps that need to be taken:

  1. The registry is contacted, and the resolver for the domain name is set
  2. The publicResolver is contacted, and the domain name is connected to your account

Domain Actions

Once you own a domain name, there are a couple of things that you could do with it.

  1. Transfer name to another account — if you have another account that you want to use the domain name you had won, you can transfer it for free
  2. Create subdomain — if you own the first-level domain (i.e. somename.eth), you are free to create as many subdomains as you want (i.e. somename.mywallet.eth)
  3. Change owners of subdomains — as long as you own the first-level domain, you can change the owners of subdomains as much as you want

Rules for Resolving a Name

ens registry

1. Normalize and hash the name — since the domain name can vary in length and content, it is first normalized and hashed
2. Query ENS registry — a query is made to the ENS registry about the availability of the domain name that you want to buy, and the registry returns a resolver
3. Query Resolver — a query is made to the resolver which returns the actual Ethereum address

Record type

Record types are also a bit different from DNS as they can be:

  • Ethereum addresses
  • ENS Names
  • ABI specifications
  • Public keys

Conclusion

People don’t like abstract things because they make their lives difficult. Seeing an Ethereum wallet address in its current state could further delay the acceptance of decentralized apps.

When it comes to presenting both this platform and the complete blockchain industry to mainstream users, Ethereum Name Service could be a huge leap forward. Although it seems like a small step for technology, it is actually a big one towards creating a decentralized world.

Follow us and subscribe for more deep dives into the technology like this one, and feel free to join the conversation on Twitter and LinkedIn.

Our team of engineers works day in and day out on developing blockchain products, and we strive to learn more from others. Get in touch with us if you would like to share your experience so that together we can help to grow blockchain community of builders even further.


Ethereum Name Service (ENS) — Bid Farewell to Long Ethereum Addresses was originally published in MVP Workshop on Medium, where people are continuing the conversation by highlighting and responding to this story.


Guides, articles, and news
Uncategorized

RWA Marketplace Validation Use Case – Tokenized RWAs are yet to take off

As the bull market kicks off, we are seeing exciting new trends taking over the market from DePINs, tokenized RWA,

Uncategorized

ZKSIM – Revolutionizing ZK Circuit Testing

The development of zero-knowledge (ZK) circuits is an intricate process, with testing posing a considerable challenge that often extends timelines

Uncategorized

FHE Project comparison

As the adoption of this transformative technology continues to grow, so does the emergence of innovative projects harnessing its capabilities.

get in touch