---
eip: 137
label: ERC-137
title: Ethereum Domain Name Service - Specification
status: Final
type: Standards Track
category: ERC
created: 2016-04-04
official: https://eips.ethereum.org/EIPS/eip-137
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-137.md
canonical: https://eips.huatuo.xyz/eip-137/
lang: en
tldr: "The Ethereum Name Service spec: a registry plus pluggable resolvers that turn names like foo.eth into addresses and other records, using the namehash algorithm."
tags: [ens, naming, registry, resolver]
---

# ERC-137: Ethereum Domain Name Service - Specification

> This draft EIP describes the details of the Ethereum Name Service, a proposed protocol and ABI definition that provides flexible resolution of short, human-readable names to service and resource identifiers.

**TL;DR:** The Ethereum Name Service spec: a registry plus pluggable resolvers that turn names like foo.eth into addresses and other records, using the namehash algorithm.

## What problem does it solve?

Addresses such as `0x8e23…d052` are impossible to remember and easy to mistype. Early Ethereum name registries had one global namespace, one central resolver, a single record type and no subdomains.

ERC-137 defines the Ethereum Name Service (ENS): a hierarchical, DNS-like system where the owner of `mysite.eth` can create `forum.mysite.eth`, point the name at a wallet, a contract or other resources, and change those targets later without changing the name.

## How it works

ENS has three parts:

- **Registry.** One contract mapping each name to an owner, a resolver and a TTL. The owner of a name can set its resolver and create subnames with different owners.
- **Resolvers.** Contracts that answer lookups. A resolver advertises which record types it supports via [ERC-165](/eip-165/) `supportsInterface`. The base type is `addr(node)` (interface `0x3b3b57de`); others, such as `name` from [ERC-181](/eip-181/), are defined in later proposals.
- **Registrars.** Whoever owns a name node and hands out its subnames. How names are allocated is left to each registrar.

Names are never stored as strings on chain. They are normalized (UTS-46, case-folded) and hashed with **namehash**, which produces a 32-byte "node":

```python
def namehash(name):
    if name == '':
        return b'\0' * 32
    label, _, rest = name.partition('.')
    return keccak256(namehash(rest) + keccak256(label))
```

So `namehash("eth")` is `0x93cdeb70…c4ae`. Because the node depends only on the name, a contract can hard-code it.

Resolving is two steps: ask the registry for the resolver of `node`, then ask the resolver for the record.

## Sample code

Resolving a name and doing a reverse lookup with ethers v6:

```ts
import { JsonRpcProvider, namehash } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);

const node = namehash("vitalik.eth");          // 32-byte node
const resolver = await provider.getResolver("vitalik.eth");
const addr = await resolver?.getAddress();      // calls addr(node)
console.log(node, addr);

// Reverse direction (ERC-181)
const name = await provider.lookupAddress(addr!);
```

A minimal resolver in Solidity:

```solidity
contract SimpleResolver {
    mapping(bytes32 => address) public addr;     // addr(bytes32)
    function supportsInterface(bytes4 id) external pure returns (bool) {
        return id == 0x3b3b57de || id == 0x01ffc9a7;
    }
}
```

## Things to know

- If `addr` returns the zero address, clients **must** treat the name as unresolved and refuse to send funds. Skipping this check can burn funds.
- Names should be normalized before hashing. Different Unicode forms of the "same" name produce different nodes, and look-alike names are a phishing risk.
- The spec recommends labels of 64 characters or less and full names of 255 or less for DNS compatibility.
- ERC-137 deliberately does not define how names are registered or priced. The `.eth` registrar and its auction or rental rules are separate contracts built on top.
- Later proposals extend resolvers, for example [ERC-3668](/eip-3668/) (CCIP Read) lets a resolver fetch records from off-chain sources.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-137
