Significance of the ENS
One of the common issues with cryptocurrencies is the mistyping of wallet addresses. ENS solves the issue and makes the transfers easier. The ENS (Ethereum Name Service) provides a service for web3 that is similar to DNS (Domain Name System), which provides a service for web2. However, there are many differences between the two services, which will be discussed later.
ENS can help you create web3 app domains very easily and securely. Your domains will be stored in the Ethereum blockchain, which is much more secure than traditional DNS. For instance, in October 2020, Google's threat analysis group monitored a record-breaking 180,000 attacks on DNS as well as on other network targets that were launched by Chinese internet service providers. By using ENS, you can avoid these kinds of security threats and keep your web3 app safe and sound.
The released domain names are secured by squatters by dutch auction which will be conducted once a domain is released. Users can set subdomains without any limit and users have access to assign new owners for the domains and sub domains.
An ENS domain with an .eth TLD (top-level domain) is an NFT. So, it can be traded like an NFT in marketplaces like Open Sea. For example, Alice.eth is an NFT, but Alice.xyz is not an NFT.
ENS domains are a great way to manage multiple web services in one easy-to-use, decentralized address. ENS can reference multiple resources at once, like IPFS hashes for a website address, ETH addresses for payments/wallets, and even Twitter handles, emails and avatars. So ENS domains can handle multiple services, which is not possible in the case of DNS. This makes ENS domains a great choice for managing an entire online entity with its underlying pieces.
The following records can be added to the ENS domains
- ETH/BTC/Doge/LTC/Atom/Dash +40 other wallet addresses.
- IPFS content hashes.
- Custom text records
- Github handles
- Twitter handles
- Email addresses
- Telegram and reddit handles
Difference between ENS and DNS
Advantages of ENS over DNS
Security and decentralization: The security is very high in ENS when compared to DNS. The domains are secured by the Ethereum blockchain, and ENS is decentralized. So there is no censorship resistance, and The protocol is transparent.
ENS aims to prevent domain squatting by the vickerey auction.
Efficiency and simplicity:
ENS simplifies the transactions of the cryptocurrency. We can register our owned DNS domains in ENS. ENS domains can have multiple use cases example, they can be used for payments, web domains(can be used for multiple websites), Twitter handles, email addresses, etc.The domain names can have emojis in ENS.The domains are very cheap when compared to DNS as the protocol is decentralized.
Regarding DNS, we need to pay separate amounts for services depending on the features we want. For example, the pay rate for basic DNS services is different than the pay rate for advanced DNS features. Therefore, if we want more features, we need to be prepared to pay more.
How ENS works
ENS contains two main smart contracts which are responsible for the working of the ENS domains. They are registry and resolver.The registry contract contains all the necessary information like the owner address of the domain,the address of the resolver contract, etc.The resolver contract manages the queries, mapping of ens names to addresses, etc.
This is the smart contract that stores all the domains and subdomains with the following.
- Address of the owner
- Address of resolver contract
- TTL(Time-to-live) which the time period for the expiration.
All the records are stored in Record(struct data type). The domain names are mapped as hashes using namehash algorithm and called nodes. The nodes are mapped to the Record, which contains the addresses of the owner, the resolver contract, and the Time-to-live value.
The domains are not directly stored in registry. Instead, they are stored as hashes. This has been done to prevent spamming and also for storage optimization. Hashes are excellent for providing a fixed-length identifier that can be passed around easily between contracts. There's no overhead and no worries about variable-length strings . The names are hashed with the algorithm called “namehash.”
Before being hashed with namehash, names are first normalized using a process called UTS-46 normalization. This ensures that upper- and lower-case names are treated equivalently, and that invalid characters are prohibited.
The owner of the domain can set a new owner and can set the resolver and TTL. Owners have complete control of the subdomains. The registry contract is responsible for creating sub-domains, assigning an owner to the subdomains, setting the TTL for the domain, mapping the node to the resolver for the queries, etc.
The ENS registry is deployed at 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e. This same address is used across Mainnet, Ropsten, Rinkeby, and Goerli.
On the mainnet, the following registrars are deployed:
- .eth, using the .eth Permanent registrar. The Permanent Registrar is the code that will govern the allocation and renewal of names in the .eth TLD(Top level domain).
- .xyz, via DNS integration(this is for DNS integrations)
- .luxe, via a custom integration that allows any owner of a .luxe DNS name to use ENS.
- .kred, via a custom integration that synchs and changes to a .kred ENS token to DNS automatically.
The registry is responsible for storing all the information and data. It maps the nodes to the resolver.Resolvers are responsible for translating the name to the addresses or other data provided by the user. Resolving a name in ENS is a two-step process: First, ask the registry what resolver is responsible for the name, and second, ask that resolver for the answer to your query. A resolver can be any contract that meets the relevant standards to act as a resolver.
Different record types have different interfaceIDs. These interfaceID help us determine whether the resolver can support the data type or not. In the above case, the interfaceID is for an Ethereum address. So we are checking whether it can support that type of record.
After owning the domain successfully, the user needs to set a resolver it can be either a public resolver or a custom resolver according to their needs.Users can set their text records in the text records section.
The public resolver implements the following EIPs:
The following functionalities are implemented in the public resolver. For normal users, the public resolver is enough as it implements most of the functionalities for managing the queries. For example, a public resolver has interface detection(which was explained above). A public resolver with text record functionality can use ENS domains for email, twitter, GitHub, and other online identification purposes.
- EIP 137 - Contract address interface (addr()).
- EIP 165 - Interface Detection (supportsInterface()).
- EIP 181 - Reverse resolution (name()).
- EIP 205 - ABI support (ABI()).
- EIP 619 - SECP256k1 public keys (pubkey()).
- EIP 634 - Text records (text()).
- EIP 1577 - Content hash support (contenthash()).
- EIP 2304 - Multicoin support (addr())
Users can buy a available domain,after buying the domain user must set up the addresses for wallet and resolver.User can set a public resolver or a custom resolver. name is hashed and recorded in the registry, along with their node's address, resolver address, and TTL. The nodes are mapped to the record, which has the owner’s address, resolver address, and TTL. we need to assign the resolver after owning the domain successfully. we can set up a public resolver that has most of the necessary functionalities. However, users can also create and use their own custom resolvers according to their specific needs.
Resolving a name in ENS is a two-step process: First, ask the registry what resolver is responsible for the name, and second, ask that resolver for the answer to your query. The domain is owned by the owner till the deadline after that the owner has to renew it within 90 days' grace time. After the grace period, the name is released for registration by anyone with a temporary premium which decreases over a 28 days period to prevent domain squatters.The released and registered names can be viewed in Dune analytics dashboard.Anyone can extend a domain’s expiration period but the ownership is still maintained by the owner of that domain.
Currently registration and renewal cost $5/year for names that are five characters or longer. Four character names cost $160/year, and three character names cost $640/year. Fees are paid in ETH.
ENS as NFTs
Ens domains with .eth are NFTs because they are in ERC-721 standards.All NFTs have a unique uint256 tokenID from which we can convert to the actual content or art or data. The domains with .eth are traded and exchanged like NFTs.The tokenID’s are globally unique.
Deriving tokenID from the ENS name,
For example, to derive tokenID for the domain harry.eth we use the following code to implement.
we are using etherjs predefined functions to produce the keccak256 hash of the name, and we are converting the hash to the number using BigNumber method, then it is converted to a string.
Turning subdomain into an NFT
Currently, all the subdomains or non .eth domains are not considered as NFTs. If we want to make these domains as NFTs, we need to create a registrar. For turning a subdomain into an NFT, we need to create smart contracts. For non-technical users, there is no direct way for conversion.
- Create a registrar contract as ERC721 compliant
- Set ENS registry address (mostly when you deploy the registrar)
- Create register function which calls registry.setSubnodeOwner then mint the token making the subdomain label hash as tokenId.
Once deployed, you must transfer the controller address to the contract.
Improvement proposals on ENS
Ethereum Improvement Proposals (EIPs) are proposals to improve the Ethereum protocol, including changes or additions to the Ethereum scalability and development roadmap. ENS Improvement Proposals (EIPs) provide insight into how the Ethereum Name Service (ENS) is structured and how it operates. Each proposal outlines new features or changes to be made to the protocol.
Let's look at some of the most important proposals on ENS. For more information about other proposals, refer: ENS improvement proposals.
ENS Working - EIP-137
The EIP-137 proposal explains the working model of the ENS protocol, including the registry and resolver contracts. It describes the functions and requirements of these contracts, as well as the option for adding subdomains. Finally, it outlines the main improvements to the ENS protocol, including the public resolver contract.
Conditions for ENS in initial stage- EIP-162
Initially, the registrar is restricted to allow only names with more than six characters to prevent squatters from getting valuable domain names. The ENS root node is assigned only for .eth domains, and it should be controlled by multiple parties using multi-sig wallets. These conditions are for two years, so it will be sufficient time for learning and designing an updated system with new features. After two years permanent registrar will be deployed. The multi-sig account owns the root node .eth will assign the ownership to the permanent registrar. The owners of the deeds or initial contracts are responsible for storing their names in the permanent registrar.
Name format to the initial registrar must be hashed with the sha3 algorithm. Note that the hashes submitted to the registrar are the hash of the subdomain label being registered, not the namehash as defined in EIP 137.
Name auctions are based on the Vickerey auction to avoid domain squatting. The total auction time is five days. The first three days are the bidding phase, where bidders can bid, and the last two days is the reveal phase, where every bidder must reveal their concealed bid within two days(reveal period). The minimum amount for bidding is 0.01 ether.
Deed contracts are created when a sealed bid is submitted as the initial registrar doesn’t hold the balances. The deed can be transferred by the owner in order to transfer the ownership
NOTE: The Vickerey auction mentioned was ended in 2019 after that available names can be bought without any auction.
The purpose of this proposal is to reverse the process for ENS domains. For example, if we look at Etherscan, we can see that the "from" ID is currently an address. However, after this proposed reverse solution is enacted, the address will be replaced with the ENS domain name only if that address owns a ENS domain and has set a primary ENS name.Anyone can configure a name to resolve to an address, regardless of ownership of that address. Reverse records allow the owner of an address to claim a name as authoritative for that address.
This proposal implements a new interfaceID for storing the text records by which ENS domain can be used instead of the records.we can link global keys like email,discription,url etc. We can link public keys like social media handles,github handles, etc. This is the main motive of this proposal.
ENS is a typical solution for the secure and safe transfer of cryptocurrency.It helps to create domains easily and multipurpose. However, there is no motivation to replace the DNS protocol which runs the web2.ENS provides an efficient domain by which we can transfer assets without any long addresses, we can use them for websites, Twitter handles, avatars, etc. Unlike DNS, the ENS is completely decentralized and secured by the Ethereum blockchain.ENS is a powerful protocol for web3 and makes progress easier for Dapps. Decentralization of ENS provides advantages for users like returning the ether after locking, providing multiple services, higher security, etc.
The ENS domain has two crucial smart contracts which are integral for the functioning of the ENS protocol - the registry and resolver contracts. The registry contract holds all the necessary information, while resolvers are responsible for actually translating names into addresses. Any contract that implements the relevant standards can act as a resolver in ENS. ENS domain names with .eth are NFTs, but others are not. The ENS protocol is an efficient and decentralized protocol for web domains.