EIPs Explained

ERC-6735 · Review · ERC · 2022-03-20

ERC-6735: L2 Aliasing of EVM-based Addresses

Proposes a deterministic way to write an asset or account address together with the chain path it came through, by wrapping it in per-chain offsets, so L1s, L2s and sidechains can identify each other's addresses.

What problem does it solve?

The same address can mean different things on different EVM chains, and a bridged token on an L2 usually lives at a different address from the original on L1. When a message travels from one chain to another, the receiver needs to know unambiguously which asset or account on which origin chain it refers to, and ideally which chains it passed through.

Rollups already do a form of this. Messages from L1 contracts arrive on some L2s with the sender address offset by 0x1111000000000000000000000000000000001111, so an L1 contract cannot impersonate an L2 account. ERC-6735, written by an EEA/OASIS L2 working group, generalises the idea into a single "root to leaf" naming rule for any EVM-based L1, L2, L3 or sidechain.

How it works

The idea is to bracket an address with an offset alias for each chain it lives on:

addressAlias = offsetAlias(chain) relativeAddress offsetAlias(chain)
  • The offsetAlias of a chain is built from its non-zero chainId, padded with zeros to a fixed width.
  • Ethereum Mainnet has a special offset, 0x1111…1111, matching the convention existing L2s already use.
  • The relativeAddress is either the original address on the origin chain, or an already-aliased address from another chain, so aliases nest.
  • Offsets must be ordered from the root chain outwards. An asset that went from chain A to B to C is written as:
chainId(C) chainId(B) chainId(A) relativeAddress chainId(A) chainId(B) chainId(C)

Reading the alias from the inside out gives the asset's origin address and the chain path it took.

The spec also sets out conformance levels (Level 1 to 3) for implementations that claim to follow it.

Sample code

An illustrative TypeScript helper following the bracket-and-nest structure. The spec's exact padding and encoding rules are ambiguous (see below), so treat the encoding here as an assumption, not the normative format:

const MAINNET_OFFSET = "1111" + "0".repeat(32) + "1111"; // per the spec, Ethereum L1

// Assumed encoding: chain id written as a 16-digit, zero-padded string
function offsetFor(chainId: bigint): string {
  if (chainId === 0n) throw new Error("chainId must not be zero");
  return chainId.toString().padStart(16, "0");
}

// path = chains the asset passed through after L1, in order
function addressAlias(l1Address: string, path: bigint[]): string {
  let inner = MAINNET_OFFSET + l1Address.slice(2) + MAINNET_OFFSET;
  for (const id of path) {
    const o = offsetFor(id);
    inner = o + inner + o;
  }
  return "0x" + inner;
}

// Token from Ethereum L1, bridged to chain 137
console.log(addressAlias("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", [137n]));

Things to know

  • Status: Review. It is not final. Production rollups use their own aliasing schemes; Arbitrum and Optimism, for example, add the 0x1111…1111 offset to the address arithmetically, which is a different thing from concatenating it.
  • The spec's own examples are hard to reconcile. It says chain ids are 8 bytes but pads them to 16 decimal digits, and the Mainnet offset does not follow the generic pattern. Verify against the current text before implementing.
  • Validate any address inside an alias. The spec recommends checking the ERC-55 checksum, checking that a supposed EOA has no code, and checking that a supposed token contract has the expected code hash.
  • For human-readable chain-qualified addresses, see ERC-3770 and ERC-7930 (both not yet final).

#l2 #interoperability #addresses #bridging #cross-chain

Details

Authors
Kelvin Fichter (@smartcontracts), Andreas Freund (@Therecanbeonlyone1969)
Status
Review
Type
Standards Track / ERC
Created
2022-03-20
Requires

Machine-readable: Markdown · JSON