Introduction to ENS

Ethereum Name Service (ENS) is a distributed, open, and extensible naming system based on the Ethereum blockchain. The core function of ENS is to resolve human-readable names (such as "alice.eth") into computer-recognizable identifiers, such as Ethereum addresses, other cryptocurrency addresses, content hashes, metadata, etc. In addition, ENS also supports "reverse resolution", which makes it possible to associate metadata (such as normalized names or interface descriptions) with Ethereum addresses.

ENS Functions and Architecture

The goal of ENS is similar to the Internet Name Service (DNS), but due to the functional characteristics and limitations of the Ethereum blockchain, the architecture of ENS is very different from DNS. ENS is a hierarchical naming system with dots as separators between levels, and each level is called a domain. The owner of a domain has full control over its subdomains.

The owner of a top-level domain (such as ".eth" and ".test") is a smart contract called a "registrar". These contracts define the rules for allocating subdomains. Anyone can obtain ownership of a domain name and configure it as needed according to the rules specified in these contracts. ENS also supports connecting existing DNS domain names to the ENS system to expand its functionality.

Due to the hierarchical structure of ENS, anyone who owns a domain at a certain level can create and configure subdomains for themselves or others. For example, if Alice owns "alice.eth", she can create "pay.alice.eth" and set it up as needed.

ENS deployment and use

ENS is deployed on the Ethereum mainnet and multiple testnets. If you use the ensjs Javascript library or an end-user application, these tools will automatically detect and interact with the corresponding network.
 

ENS Architecture

ENS has two main components: the registry and the resolver.
 

Introduction to the ENS Registry

The ENS registry is a smart contract that maintains a list of all names and subnames and stores three key pieces of information about each name:

  1. Owner of the name

  2. Name resolver

  3. The cache expiration time (TTL) of all records under the name

The owner of a name can be an external account (user) or a smart contract. The registrar acts as a smart contract that owns a top-level name and assigns sub-names of that name to users according to the rules in the contract.

ENS registry features

Name owners in the ENS registry have the following permissions:

  1. Set resolver and TTL: Owners can specify a resolver for their names and set a TTL.

  2. Transferring Ownership: An owner can transfer ownership of a name to another address.

  3. Change ownership of a subname: Owners can manage and modify ownership of subnames.

The main role of the ENS registry is to map a name to a resolver that is responsible for resolving that name. A resolver is a smart contract that is responsible for converting a name into an address. Any smart contract that meets the relevant standards for resolvers can be used as a resolver in ENS. For users with simple needs and infrequent address changes, a general resolver can be used.

Parser functions

Each record type (such as Ethereum address, content hash, etc.) defines a set of methods that a resolver must implement in order to provide the corresponding record. New record types can be defined at any time through the EIP standardization process, so there is no need to change the ENS registry or existing resolvers to support new record types.

Resolving a name in ENS requires two steps:

  1. Query the registry: First, the registry is queried to determine which resolver is responsible for resolving the name.

  2. Query the parser: Then, query the parser for the parsing result.

Advantages and Applications of ENS

The design of the ENS registry and resolver simplifies the management of complex addresses and enables users to easily convert human-readable names into computer-recognizable identifiers. This design not only enhances the user experience, but also provides great flexibility and extensibility, making ENS a powerful tool for blockchain naming systems.
 

Namehash mechanism

In smart contracts, interacting directly with human-readable names is inefficient due to resource constraints. Therefore, ENS uses a fixed-length 256-bit cryptographic hash to handle names. This hashing algorithm is called Namehash and is designed to generate unique hash values ​​with a hierarchical structure. For example, the Namehash of "alice.eth" is 0x787192fc5378cc32aa956ddfdedbf26b24e8d78e40109add0eea2c1a012c3dec. Internally in ENS, Namehash is used to represent names.

Namehash recursion process

Namehash is a recursive process that generates a unique hash for any valid name. By starting with the Namehash of a name (like "alice.eth"), the Namehash of any subname (like "iam.alice.eth") can be derived without having to process or know the original human-readable name "alice.eth". This property allows ENS to efficiently manage its hierarchy without having to process human-readable text strings internally.

Normalization process

Before using Namehash for hashing, the name must be normalized. This process relies on the UTS-46 standard to ensure that letters in the name are case-insensitive and invalid characters are prohibited. Any operation that hashes and resolves the name must first be normalized to ensure that all users get consistent results in the ENS system.

Importance of Namehash

The design of Namehash plays an important role in the following aspects:

  1. Efficiency: By converting human-readable names into fixed-length hashes, ENS enables efficient processing in smart contracts.

  2. Hierarchy: Namehash allows recursive generation of hashes of subnames, supporting hierarchical management of ENS.

  3. consistency: Ensure that all users receive consistent results when working with names in ENS through the process of canonicalization.
    Applications of Namehash

In the ENS system, Namehash is widely used:

  1. Name registration: When a user registers a name, ENS uses Namehash to convert the name into a hash value for storage and management.

  2. Name resolution: When resolving a name, ENS performs fast and efficient lookup and matching based on the name's Namehash.

  3. Subname Management: With the recursive nature of Namehash, users can easily manage subnames of their names without having to deal with complex text strings.

#ENS #ordi​​​ #zro #mln #ZEN $ENS $ORDI $ZRO