EIPs Explained

ERC-7950 · Final · ERC · 2025-05-22

ERC-7950: Encode chain id with transaction hash

A tiny string format, `chainId:txHash:tx`, that pairs a transaction hash with its chain ID so any tool can tell which network a transaction belongs to.

What problem does it solve?

A transaction hash on its own does not say which chain it lives on. With many EVM chains and L2s, a user pasting a hash into an explorer, a support ticket or a chat often has to explain which network it was sent on, or tools have to search several chains.

ERC-7950 defines one compact string that carries both pieces, so a link-forwarding service, wallet or explorer can route it to the right place automatically.

How it works

The string has three colon-separated parts:

chainId:txHash:tx
  • chainId is the decimal chain ID as defined by EIP-155 and its chain ID registry (1 for Ethereum mainnet).
  • txHash is the transaction hash including the 0x prefix.
  • tx is a fixed suffix that marks the string as a transaction reference, so it is not confused with an address or other identifier.

The whole string is case-insensitive. Chain ID comes first because it is what you need to route the query.

Example from the spec:

1:0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef:tx

Sample code

Encoding and decoding (TypeScript, ethers v6):

import { JsonRpcProvider } from "ethers";

export function encodeTxRef(chainId: bigint | number, txHash: string): string {
  if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) throw new Error("bad tx hash");
  return `${chainId}:${txHash.toLowerCase()}:tx`;
}

export function decodeTxRef(ref: string): { chainId: bigint; txHash: string } {
  const m = /^(\d+):(0x[0-9a-f]{64}):tx$/i.exec(ref.trim());
  if (!m) throw new Error("not an ERC-7950 tx reference");
  return { chainId: BigInt(m[1]), txHash: m[2].toLowerCase() };
}

// Look up the transaction on the right network
const { chainId, txHash } = decodeTxRef(input);
const provider = new JsonRpcProvider(rpcUrlFor(chainId)); // your chainId -> RPC map
const tx = await provider.getTransaction(txHash);

Things to know

  • Status: Final.
  • The order is chainId then hash then tx; it is not the same layout as CAIP-10 style account IDs, so don't reuse an address parser blindly.
  • Because the format is case-insensitive, normalise to lowercase before comparing or storing.
  • The standard only defines the string. Whether and how wallets and explorers accept it is up to each service.

#transactions #chain-id #format #explorers #multichain

Details

Authors
Lauri Peltonen (@microbecode)
Status
Final
Type
Standards Track / ERC
Created
2025-05-22
Requires

Machine-readable: Markdown · JSON