{"eip":7950,"title":"Encode chain id with transaction hash","description":"Encode a chain ID and transaction hash into a unique string format","authors":["Lauri Peltonen (@microbecode)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2025-05-22","requires":[155],"discussionsTo":"https://ethereum-magicians.org/t/a-new-standard-for-encoding-chain-id-transaction-hash/23782","repo":"ERCs","label":"ERC-7950","officialUrl":"https://eips.ethereum.org/EIPS/eip-7950","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7950.md","url":"https://eips.huatuo.xyz/eip-7950/","tldr":{"en":"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.","ja":"トランザクションハッシュにチェーン ID を組み合わせる、ごく小さな文字列フォーマット `chainId:txHash:tx`。どのツールでも、トランザクションがどのネットワークに属するかが分かるようになる。","ko":"트랜잭션 해시를 체인 ID와 짝지어, 어떤 도구든 트랜잭션이 어느 네트워크에 속하는지 알 수 있게 하는 아주 작은 문자열 형식 `chainId:txHash:tx`.","zh":"一种极小的字符串格式 `chainId:txHash:tx`，将交易哈希与其链 ID 配对，使任何工具都能判断一笔交易属于哪个网络。"},"tags":["transactions","chain-id","format","explorers","multichain"],"explainers":{"en":{"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"],"related":[155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7950/","markdown":"## What problem does it solve?\n\nA 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.\n\nERC-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.\n\n## How it works\n\nThe string has three colon-separated parts:\n\n```\nchainId:txHash:tx\n```\n\n- `chainId` is the decimal chain ID as defined by [EIP-155](/eip-155/) and its chain ID registry (1 for Ethereum mainnet).\n- `txHash` is the transaction hash *including* the `0x` prefix.\n- `tx` is a fixed suffix that marks the string as a transaction reference, so it is not confused with an address or other identifier.\n\nThe whole string is case-insensitive. Chain ID comes first because it is what you need to route the query.\n\nExample from the spec:\n\n```\n1:0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef:tx\n```\n\n## Sample code\n\nEncoding and decoding (TypeScript, ethers v6):\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nexport function encodeTxRef(chainId: bigint | number, txHash: string): string {\n  if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) throw new Error(\"bad tx hash\");\n  return `${chainId}:${txHash.toLowerCase()}:tx`;\n}\n\nexport function decodeTxRef(ref: string): { chainId: bigint; txHash: string } {\n  const m = /^(\\d+):(0x[0-9a-f]{64}):tx$/i.exec(ref.trim());\n  if (!m) throw new Error(\"not an ERC-7950 tx reference\");\n  return { chainId: BigInt(m[1]), txHash: m[2].toLowerCase() };\n}\n\n// Look up the transaction on the right network\nconst { chainId, txHash } = decodeTxRef(input);\nconst provider = new JsonRpcProvider(rpcUrlFor(chainId)); // your chainId -\u003e RPC map\nconst tx = await provider.getTransaction(txHash);\n```\n\n## Things to know\n\n- **Status: Final.**\n- 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.\n- Because the format is case-insensitive, normalise to lowercase before comparing or storing.\n- The standard only defines the string. Whether and how wallets and explorers accept it is up to each service.\n"},"ja":{"lang":"ja","tldr":"トランザクションハッシュにチェーン ID を組み合わせる、ごく小さな文字列フォーマット `chainId:txHash:tx`。どのツールでも、トランザクションがどのネットワークに属するかが分かるようになる。","tags":["transactions","chain-id","format","explorers","multichain"],"related":[155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7950/","markdown":"## 何を解決するのか\n\nトランザクションハッシュだけでは、それがどのチェーンにあるのか分かりません。多くの EVM チェーンや L2 がある中で、ユーザーがハッシュをエクスプローラー、サポートチケット、チャットに貼り付けるとき、どのネットワークで送信したのかを説明する必要があったり、ツールが複数のチェーンを検索しなければならなかったりすることがよくあります。\n\nERC-7950 は、その両方を含む 1 つのコンパクトな文字列を定義します。これにより、リンク転送サービス、ウォレット、エクスプローラーが、自動的に正しい場所へ振り分けられます。\n\n## 仕組み\n\n文字列はコロンで区切られた 3 つの部分からなります。\n\n```\nchainId:txHash:tx\n```\n\n- `chainId` は、[EIP-155](/eip-155/) とそのチェーン ID レジストリで定義される 10 進数のチェーン ID です（Ethereum メインネットは 1）。\n- `txHash` は、`0x` プレフィックスを*含む*トランザクションハッシュです。\n- `tx` は固定のサフィックスで、その文字列がトランザクション参照であることを示し、アドレスや他の識別子と混同されないようにします。\n\n文字列全体は大文字小文字を区別しません。チェーン ID が最初にあるのは、クエリをルーティングするのに必要なのがそれだからです。\n\n仕様にある例:\n\n```\n1:0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef:tx\n```\n\n## サンプルコード\n\nエンコードとデコード（TypeScript、ethers v6）:\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nexport function encodeTxRef(chainId: bigint | number, txHash: string): string {\n  if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) throw new Error(\"bad tx hash\");\n  return `${chainId}:${txHash.toLowerCase()}:tx`;\n}\n\nexport function decodeTxRef(ref: string): { chainId: bigint; txHash: string } {\n  const m = /^(\\d+):(0x[0-9a-f]{64}):tx$/i.exec(ref.trim());\n  if (!m) throw new Error(\"not an ERC-7950 tx reference\");\n  return { chainId: BigInt(m[1]), txHash: m[2].toLowerCase() };\n}\n\n// Look up the transaction on the right network\nconst { chainId, txHash } = decodeTxRef(input);\nconst provider = new JsonRpcProvider(rpcUrlFor(chainId)); // your chainId -\u003e RPC map\nconst tx = await provider.getTransaction(txHash);\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final。**\n- 順序は `chainId`、ハッシュ、`tx` の順です。CAIP-10 スタイルのアカウント ID とはレイアウトが異なるため、アドレスのパーサーをそのまま流用しないでください。\n- フォーマットは大文字小文字を区別しないため、比較や保存の前に小文字に正規化してください。\n- この標準が定義するのは文字列だけです。ウォレットやエクスプローラーがそれを受け付けるかどうか、どのように受け付けるかは、各サービス次第です。\n"},"ko":{"lang":"ko","tldr":"트랜잭션 해시를 체인 ID와 짝지어, 어떤 도구든 트랜잭션이 어느 네트워크에 속하는지 알 수 있게 하는 아주 작은 문자열 형식 `chainId:txHash:tx`.","tags":["transactions","chain-id","format","explorers","multichain"],"related":[155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7950/","markdown":"## 어떤 문제를 해결하나요?\n\n트랜잭션 해시만으로는 그것이 어느 체인에 있는지 알 수 없습니다. EVM 체인과 L2가 많다 보니, 사용자가 해시를 탐색기, 지원 티켓, 채팅에 붙여 넣을 때 어느 네트워크에서 보낸 것인지 설명해야 하거나, 도구가 여러 체인을 검색해야 하는 경우가 많습니다.\n\nERC-7950은 이 두 가지를 모두 담은 간결한 문자열 하나를 정의합니다. 그러면 링크 전달 서비스, 지갑, 탐색기가 이를 자동으로 올바른 곳으로 라우팅할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n문자열은 콜론으로 구분된 세 부분으로 이루어집니다.\n\n```\nchainId:txHash:tx\n```\n\n- `chainId`는 [EIP-155](/eip-155/)와 그 체인 ID 레지스트리가 정의한 10진수 체인 ID입니다(이더리움 메인넷은 1).\n- `txHash`는 `0x` 접두어를 *포함한* 트랜잭션 해시입니다.\n- `tx`는 고정 접미어로, 이 문자열이 트랜잭션 참조임을 표시해 주소나 다른 식별자와 혼동되지 않게 합니다.\n\n문자열 전체는 대소문자를 구분하지 않습니다. 쿼리를 라우팅하는 데 필요한 것이 체인 ID이므로 체인 ID가 맨 앞에 옵니다.\n\n스펙의 예:\n\n```\n1:0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef:tx\n```\n\n## 샘플 코드\n\n인코딩과 디코딩(TypeScript, ethers v6):\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nexport function encodeTxRef(chainId: bigint | number, txHash: string): string {\n  if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) throw new Error(\"bad tx hash\");\n  return `${chainId}:${txHash.toLowerCase()}:tx`;\n}\n\nexport function decodeTxRef(ref: string): { chainId: bigint; txHash: string } {\n  const m = /^(\\d+):(0x[0-9a-f]{64}):tx$/i.exec(ref.trim());\n  if (!m) throw new Error(\"not an ERC-7950 tx reference\");\n  return { chainId: BigInt(m[1]), txHash: m[2].toLowerCase() };\n}\n\n// Look up the transaction on the right network\nconst { chainId, txHash } = decodeTxRef(input);\nconst provider = new JsonRpcProvider(rpcUrlFor(chainId)); // your chainId -\u003e RPC map\nconst tx = await provider.getTransaction(txHash);\n```\n\n## 알아둘 점\n\n- **상태: Final.**\n- 순서는 `chainId`, 해시, `tx`입니다. CAIP-10 스타일의 계정 ID와는 레이아웃이 다르므로 주소 파서를 그대로 재사용하지 마세요.\n- 형식이 대소문자를 구분하지 않으므로, 비교하거나 저장하기 전에 소문자로 정규화하세요.\n- 이 표준은 문자열만 정의합니다. 지갑과 탐색기가 이를 받아들일지, 어떻게 받아들일지는 각 서비스에 달려 있습니다.\n"},"zh":{"lang":"zh","tldr":"一种极小的字符串格式 `chainId:txHash:tx`，将交易哈希与其链 ID 配对，使任何工具都能判断一笔交易属于哪个网络。","tags":["transactions","chain-id","format","explorers","multichain"],"related":[155],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7950/","markdown":"## 它解决什么问题？\n\n仅凭一个交易哈希，并不能说明它位于哪条链上。EVM 链和 L2 众多，用户把哈希粘贴到区块浏览器、工单或聊天中时，往往要解释它是在哪个网络上发送的，或者工具必须在多条链上搜索。\n\nERC-7950 定义了同时携带这两部分信息的一个紧凑字符串，这样链接转发服务、钱包或区块浏览器就可以自动把它路由到正确的位置。\n\n## 它如何运作\n\n该字符串由三个以冒号分隔的部分组成：\n\n```\nchainId:txHash:tx\n```\n\n- `chainId` 是由 [EIP-155](/eip-155/) 及其链 ID 注册表定义的十进制链 ID（以太坊主网为 1）。\n- `txHash` 是*包含* `0x` 前缀的交易哈希。\n- `tx` 是固定的后缀，用来标明该字符串是一个交易引用，从而不会与地址或其他标识符混淆。\n\n整个字符串不区分大小写。链 ID 放在最前面，因为路由查询需要的正是它。\n\n规范中的示例：\n\n```\n1:0xc55e2b90168af6972193c1f86fa4d7d7b31a29c156665d15b9cd48618b5177ef:tx\n```\n\n## 示例代码\n\n编码和解码（TypeScript，ethers v6）：\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nexport function encodeTxRef(chainId: bigint | number, txHash: string): string {\n  if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) throw new Error(\"bad tx hash\");\n  return `${chainId}:${txHash.toLowerCase()}:tx`;\n}\n\nexport function decodeTxRef(ref: string): { chainId: bigint; txHash: string } {\n  const m = /^(\\d+):(0x[0-9a-f]{64}):tx$/i.exec(ref.trim());\n  if (!m) throw new Error(\"not an ERC-7950 tx reference\");\n  return { chainId: BigInt(m[1]), txHash: m[2].toLowerCase() };\n}\n\n// Look up the transaction on the right network\nconst { chainId, txHash } = decodeTxRef(input);\nconst provider = new JsonRpcProvider(rpcUrlFor(chainId)); // your chainId -\u003e RPC map\nconst tx = await provider.getTransaction(txHash);\n```\n\n## 需要注意\n\n- **状态：Final。**\n- 顺序是 `chainId`、哈希、`tx`；这与 CAIP-10 风格的账户 ID 布局不同，所以不要盲目复用地址解析器。\n- 由于该格式不区分大小写，在比较或存储之前请统一规范为小写。\n- 该标准只定义了这个字符串。钱包和区块浏览器是否接受它、如何接受它，取决于各自的服务。\n"}}}
