Skip to content

Nish0483/custom-ENS-TLD

Repository files navigation

Custom Top-Level-Domain (TLD) in ENS

This project is for creating a custom TLD like "example.nish" in using Ethereum Name Service ENS . Creating a custom domain rather than "example.eth" involves usage of DNS domains in accordance with ENS contracts

Getting Started

Follow these steps to get your custom ENS TLD

Prerequisites

  • Node.js installed
  • Ethereum wallet with sufficient funds for transactions (goerli used here)

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/custom-ens-tld.git
    
  2. Navigate to the project directory:

    cd custom-ens-tld
    
    
  3. install dependencies

    npm install
    
  4. Create a .env file in root folder with

    PRIVATE_KEY=<your wallet pvt key>
    API_KEY=https://goerli.infura.io/v3/<ur infura api key>
    
  5. compile contracts

     npx hardhat compile
    
    
  6. Deploy

    npm hardhat deploy --network goerli
    
    

contracts

  • ENSRegistry:

The ENSRegistry contract is the core contract managing the ENS system. It maintains a mapping between domain names (represented as Ethereum hashes) and their corresponding owners. It also handles the assignment of subdomains to different owners.

  • Resolver:

The Resolver contract is associated with each domain registered in the ENS system. It contains information about the domain, such as the address associated with the domain (e.g., an Ethereum address). Users can interact with the Resolver to update or retrieve information linked to a specific domain.

  • Registrar:

The Registrar contract manages the registration of new domains within the ENS system. It ensures that users can claim ownership of a domain name by following a specific registration process. The Registrar contract may have additional features like handling the release of expired domains or managing the auction process for premium names.

  • PublicSuffixList:

The PublicSuffixList is often an external contract or library used to validate domain names and ensure they conform to public suffix rules. It helps prevent certain types of attacks and ensures that users cannot claim certain reserved or high-level domains.

  • DNSSEC (Domain Name System Security Extensions):

DNSSEC is a set of extensions to DNS that adds an additional layer of security to the domain name system. In the context of ENS, a 'DNSSEC oracle contract' may be used to verify DNSSEC proofs provided during the domain claiming process. DNSSEC ensures the integrity and authenticity of DNS data associated with a domain.

  • More deails of contracts deployment order , and calling of their specific functions are explained in deploy.js

sample deployment address in goerli

  1. ensRegistry : https://goerli.etherscan.io/address/0xBde345E46BD6E069c59A1Af6730854e54A9B60e6
  2. custom resolver : https://goerli.etherscan.io/address/0x780030179dCF446D8307e13D8a73f9443E478C94
  3. SuffixList: https://goerli.etherscan.io/address/0x431287da921Da5AFfC7C3887415A69e76094E050
  4. DNSSEC impl : https://goerli.etherscan.io/address/0x6d6944E3C9D9f1eFe90A5a4594F2B63E5d6D686a
  5. DNS Registrar : https://goerli.etherscan.io/address/0x2F0A47e43877Be7fEb376fE3fC628681d0959cF1

Claiming process

Running the deploy.js in scripts folder in hardhat will deploy necessory contracts

claiming onchain :

The DNSRegistrar contract can help with claiming of DNS domain in ENS Since 2021, it has been possible to import a DNS name and use that as an ENS name. This process involves enabling DNSSEC, setting a specific TXT record, and submitting a proof to the DNSRegistrar smart contract.

Expect your TXT record to look something like this:

TXT @ _ens a=<eth-address>

There is no ENS protocol fee to import a DNS name, but it requires a large amount of gas (up to a few million !!!) to submit the proof onchain. Continue reading to learn how this has been mitigated.

claiming off chain :

EP5.1 introduced a new DNSSECOracle and DNSRegistrar which makes it possible to perform DNSSEC verification at query time, enabling truly free usage of DNS names in ENS. We call this "gasless DNSSEC".

It works by enabling wildcard resolution at the DNS TLD level. During the name resolution process, if a name doesn't already exist onchain but has been configured for usage in ENS, the DNSSEC proof will be fetched offchain via CCIP Read and then verified onchain with the same DNSSECOracle mentioned above.

To configure a DNS name for usage in ENS, simply add a TXT record with the following format:

TXT @ ENS1 <resolver-address>

And here are the key points >>>

  1. DNS (Domain Name System): The Domain Name System (DNS) is a decentralized hierarchical system that translates human-readable domain names (like www.example.com) into IP addresses that machines on the internet use to identify each other. DNS plays a crucial role in enabling users to access websites using domain names rather than IP addresses.

  2. ENS : ENS stands for Ethereum Name Service. It is a decentralized domain name system built on the Ethereum blockchain. ENS allows users to register and manage domain names ending in ".eth" or custom top level domain like our case using DNS

  3. DNS Record: DNS records are entries within the DNS database that provide information about a domain. Each record has a specific type and purpose. Common types of DNS records include A (IPv4 address), AAAA (IPv6 address), CNAME (canonical name), MX (mail exchange), TXT (text), and more.

  4. TXT Record: A TXT (Text) record is a type of DNS record that allows domain owners to associate arbitrary text with a domain. It's commonly used for various purposes, and verification of domain is one of it like in our case

*** FAQ : How to get/ edit TXT ?

TXT is part of DNS domain record. Inorder to get that u need to own a domain first. You can use paid or free providers for testing. In either case the platform should support DNSSEC security.After getting domain you need to go to its control panel in which domain setting are available. A zone file/ UI setup will be availble which contain all the record as explained above . And thats where we add/edit the TXT field accordingly

NOTE

In prove and claim call in DNSRegistar the input DNSSEC.RRSetWithSignature[] is array of each signed dns record (structure of bytes rrset,bytes signature) .Inorder to sign this we need a private key also from dns manager which sometime managed by platform it-self especially in free providers can trouble with process.

Read more