---
eip: 7785
label: ERC-7785
title: Onchain registration of chain identifiers
status: Draft
type: Standards Track
category: ERC
created: 2024-09-26
requires: 2304
official: https://eips.ethereum.org/EIPS/eip-7785
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7785.md
canonical: https://eips.huatuo.xyz/eip-7785/
lang: en
tldr: "Proposes deriving new chain IDs as a 32-byte hash of the chain's name and registering name-to-ID mappings in ENS, replacing the centrally maintained chain list and preventing spoofed chain names."
tags: [chain-id, ens, l2, registry, interoperability]
---

# ERC-7785: Onchain registration of chain identifiers

> Derive chain identifiers by hashing their chain name and use ENS to map chain names to these identifiers

**TL;DR:** Proposes deriving new chain IDs as a 32-byte hash of the chain's name and registering name-to-ID mappings in ENS, replacing the centrally maintained chain list and preventing spoofed chain names.

## What problem does it solve?

Every EVM chain has a numeric chain ID (mainnet is `1`), used for replay protection since [EIP-155](/eip-155/). The mapping from names to IDs lives in a community-maintained list on GitHub. With the number of L2s growing fast, that list:

- does not scale well, and
- makes its maintainers a single point of failure.

The list does one important job: it keeps names and IDs **one-to-one**. Without that, an attacker could register an innocent-looking name such as `my-testnet` pointing at chain ID `1`, trick a user into signing what they think is a testnet transaction, then replay it on mainnet.

ERC-7785 aims for censorship-resistant registration, trustless resolution and a unique name-to-ID mapping.

## How it works

**Hash-derived IDs.** New chain IDs grow to 32 bytes and are computed with a cryptographic hash whose input must include the chain name, and may include more. The spec's example for an L2:

```
chain_id = keccak256(CHAIN_NAME, SETTLEMENT_CHAIN_ID, VERSION, DEPLOYER_CONTRACT_ADDRESS, SALT)
```

Because the ID is a digest of the name, nobody can register a different name that maps to an existing ID.

**ENS resolution.** An ENS name resolves to the chain ID using the multichain resolution scheme of [ERC-2304](/eip-2304/), together with the extra inputs needed to recompute it, e.g. `rollup.eth → {version, bridge, chain_id}`. A client verifies by recomputing the hash and checking it matches.

**Legacy IDs.** Existing short IDs cannot be recomputed, so the spec uses a reverse record under `chainid.reverse`: resolve `legacy-rollup.eth → 0x123`, then resolve `0x123` in `chainid.reverse` and check it returns `legacy-rollup`. It sketches a bootstrap in which the Ethereum Foundation seeds `l2.eth` and `chainid.reverse` from the existing lists and hands records over to each rollup.

## Sample code

Verifying a hash-derived chain ID (illustrative; the exact encoding of the hash inputs is not fixed by the spec):

```ts
import { solidityPackedKeccak256 } from "ethers";

// Record fetched from ENS for "rollup.eth"
const record = { version: 1n, bridge: "0x1234...abcd", chainId: "0x…32-byte id…" };

const expected = solidityPackedKeccak256(
  ["string", "uint256", "uint256", "address"],
  ["rollup", 1n /* settlement chain: mainnet */, record.version, record.bridge],
);

if (expected.toLowerCase() !== record.chainId.toLowerCase()) {
  throw new Error("chain id does not match name: possible spoofing");
}
```

## Things to know

- **Status: Draft.** The Rationale section is still "TBD", and the exact hash input encoding is not yet specified.
- Hash-derived IDs are much larger than today's short IDs, so wallets and tools that assume small integer chain IDs would need checking before relying on them.
- Domain squatting on chain names is possible, though the spec notes the GitHub list faces the same issue.
- Related work on naming chains and addresses: [ERC-3770](/eip-3770/) (chain-specific address prefixes) and [ERC-7930](/eip-7930/) (interoperable addresses).
- [ERC-2304](/eip-2304/), used for resolution, is itself Stagnant.


---

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