Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article explores ERC7785, which proposes deriving and verifying blockchain identifiers from chain names using ENS for decentralized, secure management.

This article translates, summarizes, and supplements the material linked below.

I have also covered various EIPs, BIPs, SLIPs, and CAIPs.

Overview

ERC7785 proposes deriving a blockchain’s chain identifier as a digest computed from information such as its chain name. Rather than centrally managing the mapping between chain names and identifiers on GitHub, the proposal aims to enable decentralized registration and resolution using ENS (Ethereum Name Service). It also provides a way to support existing chain identifiers that do not follow the new rules.

Motivation

Chain names and identifiers (for example, Mainnet → 0x1) are currently mapped in a list on GitHub. However, this approach has two problems.

  1. The number of L2s (Layer 2 networks) is growing rapidly, and centralized list management cannot scale to meet that growth.
  2. The system depends on a small number of people or organizations maintaining the list, creating a single point of failure.

The proposal therefore calls for a mechanism with the following properties.

  • New chain names and identifiers can be registered in a censorship-resistant manner.
  • Registered chain names and identifiers can be resolved trustlessly.
  • Uniqueness is maintained so that each chain name corresponds to one identifier.

Chain identifier impersonation and replay attacks

An important property guaranteed by the centralized list was the one-to-one mapping between chain names and identifiers. If that property is lost, attackers may exploit the mismatch.

Suppose an attacker registers the new name my-testnet against the existing Mainnet identifier (0x1). A user might mistake my-testnet for a safe test network and sign a transaction. In fact, the transaction is intended for Mainnet, and the attacker could replay the signed transaction there.

Specification

ERC7785 describes how to extend chain identifiers and resolve chain names to identifiers using ENS. The following sections explain identifier generation and resolution in turn.

Extending chain identifiers

Historically, chain identifiers have been short, arbitrarily chosen values. For example, the Ethereum Mainnet identifier is a small number such as 0x1. This approach cannot accommodate the rapidly growing number of blockchains.

ERC7785 therefore describes extending identifiers to 32 bytes and generating them using a cryptographic hash function. The chain name is a required hash input, and additional information can be included as needed.

For example, an L2 chain identifier is calculated as follows.

text
chain_id = Keccak-256(CHAIN_NAME, SETTLEMENT_CHAIN_ID, VERSION, DEPLOYER_CONTRACT_ADDRESS, SALT)
  • SETTLEMENT_CHAIN_ID is the identifier of the L1 chain that the L2 ultimately relies on for settlement (for example, Mainnet or Testnet).
  • VERSION is an arbitrary string that makes the hash computation unique.
  • DEPLOYER_CONTRACT_ADDRESS is the L2 contract address deployed on the L1.
  • SALT is a value providing additional uniqueness.

This provides scalability while avoiding identifier collisions.

Resolving chain names

ENS (Ethereum Name Service) enables chain names to be resolved to chain identifiers. Following ERC2304, the identifier and related information are stored in ENS records.

For more on ERC2304, see the following article.

[ERC2304] How ENS Supports Multiple Chains

For example, an L2 chain called rollup can be identified on Mainnet through ENS as follows.

text
rollup.eth -> {version : uint, bridge : address, chain_id : chain_id}

A client receiving this information verifies it as follows.

text
chain_id == hash("rollup", 0x1, version, bridge)

This mechanism lets clients derive a chain identifier from an ENS name trustlessly and verify that the mapping is correct and unique.

In other words, by resolving the name rollup.eth, users obtain information such as the L2’s chain identifier and bridge contract and can verify its validity by computing the hash.

Compatibility

ERC7785 also describes how to support legacy chain identifiers not generated by the new mechanism. It uses reverse mappings. Specifically, it provides a way to resolve an existing identifier back to a chain name and verify that the mapping is unique.

For example, if the chain name legacy-rollup.eth corresponds to the identifier 0x123, resolving 0x123 under the chainid.reverse domain returns a chain name. If the result is legacy-rollup, the mapping is accepted as valid.

Reverse resolution allows previously defined identifiers and identifiers introduced under the new mechanism to coexist.

Bootstrapping and handover

The proposal also describes bootstrapping and handover procedures for migrating existing identifiers.

  1. The Ethereum Foundation (EF) first establishes the chainid.reverse domain and a temporary l2.eth domain, registering information from the existing Ethereum list.
  2. Each rollup (L2) then registers a name such as rollup.eth and configures it to point to its own chain_id.
  3. The EF transfers control of rollup.l2.eth and chain_id.chainid.reverse to that rollup.
  4. Finally, the rollup updates chain_id.chainid.reverse itself so that it returns the correct chain name (for example, rollup.eth).

This process allows existing identifiers to migrate gradually to the new decentralized mechanism.

Security

The proposal identifies two main security concerns.

  1. Replay attacks through domain impersonation If a fake domain name is associated with an existing identifier, a transaction signed by mistake may be replayed on another chain. To prevent this, new identifiers must be derived using a hash function, while existing identifiers must be verified using reverse mappings.

  2. Domain squatting This involves registering large numbers of domain names before their intended users can obtain them, with the intention of selling them later. Although ENS is susceptible to this problem, similar challenges already exist in the centralized GitHub list, so it is recognized as a difficult problem to avoid as the number of L2s grows.

References

Marco Stronati (@paracetamolo), Jeff Lau (@jefflau), "ERC-7785: Onchain registration of chain identifiers [DRAFT]," Ethereum Improvement Proposals, no. 7785, September 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7785.

Conclusion

This article has covered ERC7785, which proposes deriving and verifying chain identifiers from chain names using ENS for decentralized, secure management.

What did you think?

If you have any questions, feel free to send me a direct message on Twitter.

Twitter @cardene777

I also publish on other platforms. Feel free to explore them.

https://chaldene.net/