EIPs Explained

ERC-7831 · Draft · ERC · 2024-08-30

ERC-7831: Multi-Chain Addressing

A human-readable address format like example.eth:optimism that names both the account and the chain, with chain names resolved through ENS instead of a centralised list.

What problem does it solve?

With many L2s sharing the same address format, a bare 0x… address no longer tells you where to send funds. Sending to the right address on the wrong chain can make funds unreachable. Chain IDs are not human-friendly, and the usual name-to-ID mapping is a centrally maintained list that does not scale with the number of chains.

ERC-7831 proposes a single string that carries both the account and the target chain, and uses ENS on a "root chain" to look up what a chain name means.

How it works

A chain-specific address has up to three colon-separated parts, from most specific (left) to most general (right):

local-part : chain-part [ : root-part ]
  • local-part: the account. Either a hex address without 0x (checksum casing required, leading zeros optional), or an ENS-style name that must contain at least one dot.
  • chain-part: an ENS label naming the target chain, e.g. optimism.
  • root-part (optional): the decimal chain ID of the root chain where ENS lookups happen. Omit it for mainnet (1); it is required otherwise.

The whole thing may be wrapped in parentheses to avoid parsing ambiguity, e.g. (example.eth:optimism).

Resolution goes right to left:

  1. Pick the root chain (default mainnet).
  2. Resolve <chain-part> under a parent ENS name to a bridge contract. The bridge must implement ChainMetadata (chainId(), coinType(), acceptsName()) and pass ERC-165 and acceptsName checks.
  3. Resolve the account: verify the checksum for hex, or resolve the ENS name with ERC-2304 multichain addr using the target chain's coin type.

The checksum is an ERC-55 variant that also works for addresses that are not 20 bytes long.

Sample code

Splitting an address into its parts (TypeScript):

type ChainSpecific = { local: string; chain: string; root: bigint };

function parseChainSpecific(input: string): ChainSpecific {
  const bare = input.startsWith("(") && input.endsWith(")") ? input.slice(1, -1) : input;
  const parts = bare.split(":");
  if (parts.length < 2 || parts.length > 3) throw new Error("expected local:chain[:root]");
  const [local, chain, root] = parts;
  if (local.startsWith("0x")) throw new Error("hex local-part must not have 0x");
  const isHex = /^[0-9a-fA-F]+$/.test(local);
  if (!isHex && !local.includes(".")) throw new Error("ENS local-part needs a dot");
  if (root !== undefined && !/^[0-9]+$/.test(root)) throw new Error("root must be decimal");
  return { local, chain, root: root ? BigInt(root) : 1n };
}

parseChainSpecific("example.eth:optimism");
// { local: "example.eth", chain: "optimism", root: 1n }
parseChainSpecific("6A10161835a36302BfD39bDA9B44f5734442234e:ethereum:11155111");
// root chain is 11155111 instead of mainnet

Things to know

  • Status: Draft, with open TODOs. The parent ENS name for chain labels is a placeholder (tbd.eth) and the bridge's ERC-165 interface ID is not final, so the format cannot be resolved end-to-end yet.
  • example.eth:optimism and example.eth:optimism:10 are different: the second resolves names against an ENS deployment on chain 10.
  • Related efforts tackle the same problem differently: ERC-3770 prefixes a short chain name (eth:0x…), and ERC-7930 defines a binary interoperable address format.
  • Wallets that do not support the format will simply reject these strings, since they are neither valid hex addresses nor plain ENS names.

#addresses #multichain #ens #l2 #ux

Details

Authors
Sam Wilson (@SamWilsn) <[email protected]>
Status
Draft
Type
Standards Track / ERC
Created
2024-08-30
Requires

Machine-readable: Markdown · JSON