---
eip: 7950
label: ERC-7950
title: Encode chain id with transaction hash
status: Final
type: Standards Track
category: ERC
created: 2025-05-22
requires: 155
official: https://eips.ethereum.org/EIPS/eip-7950
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7950.md
canonical: https://eips.huatuo.xyz/eip-7950/
lang: en
tldr: "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."
tags: [transactions, chain-id, format, explorers, multichain]
---

# ERC-7950: Encode chain id with transaction hash

> Encode a chain ID and transaction hash into a unique string format

**TL;DR:** 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](/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):

```ts
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.


---

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