{"eip":3788,"title":"Strict enforcement of chainId","description":"Reject transactions that do not explicitly have the same chainId as the node's configuration.","authors":["Gregory Markou (@GregTheGreek)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2021-09-02","requires":[155],"discussionsTo":"https://ethereum-magicians.org/t/discussion-to-eip-3788-strict-enforcement-of-chainid/7001","repo":"EIPs","label":"EIP-3788","officialUrl":"https://eips.ethereum.org/EIPS/eip-3788","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3788.md","url":"https://eips.huatuo.xyz/eip-3788/","tldr":{"en":"Proposed making nodes reject any transaction whose chainId does not match their own, closing the loophole where chainId 0 transactions can be replayed across chains.","ja":"ノードに、chainId が自身のものと一致しないトランザクションをすべて拒否させることを提案した。chainId 0 のトランザクションがチェーンをまたいでリプレイされうる抜け穴をふさぐ。","ko":"노드가 자신의 chainId와 일치하지 않는 모든 트랜잭션을 거부하도록 하자고 제안했다. chainId가 0인 트랜잭션이 체인 간에 재전송될 수 있는 허점을 막는다.","zh":"提议让节点拒绝任何 chainId 与自身不一致的交易，堵住 chainId 为 0 的交易可以跨链重放的漏洞。"},"tags":["transactions","chainid","replay-protection","security","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed making nodes reject any transaction whose chainId does not match their own, closing the loophole where chainId 0 transactions can be replayed across chains.","tags":["transactions","chainid","replay-protection","security","core"],"related":[155,2718,1559],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3788/","markdown":"## What problem does it solve?\n\n[EIP-155](/eip-155/) added a chain ID to signed transactions so a transaction signed for one network cannot be replayed on another. But, as this EIP points out, a transaction with `chainId = 0` is still treated as valid. That was kept deliberately, so developers could create transactions that work on any chain.\n\nWith many EVM-compatible networks built from forks of Ethereum clients, that escape hatch became a risk. Most wallets do not show users which chain ID they are signing. A malicious (or careless) network could get users to sign `chainId = 0` transactions and then replay them on Ethereum mainnet or elsewhere.\n\n## How it works\n\nFrom a fork block `N`, a node rejects any transaction whose chain ID differs from the chain ID in its own configuration. In particular, `chainId = 0` transactions become invalid.\n\n```text\nif node.config.chainId != tx.chainId:\n    reject(tx)\n```\n\nThe check is applied in two places:\n\n1. **JSON-RPC** (`eth_sendTransaction`, `eth_sendRawTransaction`): reject early, so users never have a transaction pending that is guaranteed to fail.\n2. **Transaction validation** during block processing: so such a transaction can never be included in a block.\n\nThe node's configured chain ID is the single source of truth.\n\n## Sample code\n\nTyped transactions ([EIP-2718](/eip-2718/), e.g. [EIP-1559](/eip-1559/) type-2) always carry an explicit `chainId`. With ethers v6 the signer fills it in from the connected provider, and you can make the intent explicit:\n\n```ts\nimport { JsonRpcProvider, Wallet, parseEther } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst wallet = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst { chainId } = await provider.getNetwork();\n\nconst tx = await wallet.sendTransaction({\n  to: \"0x000000000000000000000000000000000000dEaD\",\n  value: parseEther(\"0.001\"),\n  chainId,            // bound to this network only, never 0\n});\nconsole.log(tx.chainId); // e.g. 1n on mainnet\n```\n\n## Things to know\n\n- Status: **Stagnant**. It was never scheduled for a network upgrade.\n- The spec says it would break any application or tooling that still submits `chainId == 0` transactions after the fork block.\n- It does not stop someone from launching a network that reuses `chainId = 1` or any other existing ID. Replay protection only works when chain IDs are unique.\n- For wallets the practical lesson stands without a fork: always sign with an explicit, correct chain ID and show it to the user.\n"},"ja":{"lang":"ja","tldr":"ノードに、chainId が自身のものと一致しないトランザクションをすべて拒否させることを提案した。chainId 0 のトランザクションがチェーンをまたいでリプレイされうる抜け穴をふさぐ。","tags":["transactions","chainid","replay-protection","security","core"],"related":[155,2718,1559],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3788/","markdown":"## 何を解決するのか\n\n[EIP-155](/eip-155/) は、署名付きトランザクションにチェーン ID を追加し、あるネットワーク向けに署名されたトランザクションが別のネットワークでリプレイされないようにしました。しかし、この EIP が指摘するように、`chainId = 0` のトランザクションは今でも有効として扱われます。これは、開発者がどのチェーンでも動くトランザクションを作れるように、意図的に残されたものでした。\n\nEthereum クライアントのフォークから作られた EVM 互換ネットワークが多数ある中で、この抜け道はリスクになりました。ほとんどのウォレットは、署名しているチェーン ID をユーザーに表示しません。悪意のある（あるいは不注意な）ネットワークが、ユーザーに `chainId = 0` のトランザクションに署名させ、それを Ethereum メインネットなどでリプレイすることができます。\n\n## 仕組み\n\nフォークブロック `N` から、ノードは、チェーン ID が自身の設定にあるチェーン ID と異なるトランザクションをすべて拒否します。特に、`chainId = 0` のトランザクションは無効になります。\n\n```text\nif node.config.chainId != tx.chainId:\n    reject(tx)\n```\n\nこのチェックは 2 か所で適用されます。\n\n1. **JSON-RPC**（`eth_sendTransaction`、`eth_sendRawTransaction`）：早い段階で拒否することで、失敗が確実なトランザクションがペンディングのまま残ることがありません。\n2. ブロック処理中の**トランザクション検証**：そのようなトランザクションがブロックに取り込まれることは決してありません。\n\nノードに設定されたチェーン ID が唯一の信頼できる情報源です。\n\n## サンプルコード\n\n型付きトランザクション（[EIP-2718](/eip-2718/)、たとえば [EIP-1559](/eip-1559/) のタイプ 2）は、常に明示的な `chainId` を持ちます。ethers v6 では、署名者が接続先のプロバイダーから補完してくれますが、意図を明示することもできます。\n\n```ts\nimport { JsonRpcProvider, Wallet, parseEther } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst wallet = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst { chainId } = await provider.getNetwork();\n\nconst tx = await wallet.sendTransaction({\n  to: \"0x000000000000000000000000000000000000dEaD\",\n  value: parseEther(\"0.001\"),\n  chainId,            // bound to this network only, never 0\n});\nconsole.log(tx.chainId); // e.g. 1n on mainnet\n```\n\n## 知っておくべきこと\n\n- ステータス：**Stagnant**。ネットワークアップグレードにスケジュールされることはありませんでした。\n- 仕様は、フォークブロックの後も `chainId == 0` のトランザクションを送信し続けるアプリケーションやツールは動かなくなると述べています。\n- `chainId = 1` や、その他の既存の ID を再利用するネットワークを誰かが立ち上げるのを止めるものではありません。リプレイ保護が機能するのは、チェーン ID が一意である場合だけです。\n- ウォレットにとっての実用的な教訓は、フォークがなくても変わりません。常に明示的で正しいチェーン ID で署名し、それをユーザーに表示してください。\n"},"ko":{"lang":"ko","tldr":"노드가 자신의 chainId와 일치하지 않는 모든 트랜잭션을 거부하도록 하자고 제안했다. chainId가 0인 트랜잭션이 체인 간에 재전송될 수 있는 허점을 막는다.","tags":["transactions","chainid","replay-protection","security","core"],"related":[155,2718,1559],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3788/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-155](/eip-155/)는 서명된 트랜잭션에 체인 ID를 추가해, 한 네트워크용으로 서명된 트랜잭션이 다른 네트워크에서 재전송(replay)될 수 없게 했습니다. 하지만 이 EIP가 지적하듯, `chainId = 0`인 트랜잭션은 여전히 유효한 것으로 취급됩니다. 이는 개발자가 어떤 체인에서든 동작하는 트랜잭션을 만들 수 있도록 일부러 남겨 둔 것이었습니다.\n\n이더리움 클라이언트를 포크해 만든 EVM 호환 네트워크가 많아지면서 이 탈출구는 위험이 되었습니다. 대부분의 지갑은 서명하는 체인 ID를 사용자에게 보여 주지 않습니다. 악의적인(또는 부주의한) 네트워크가 사용자가 `chainId = 0` 트랜잭션에 서명하게 한 다음, 이를 이더리움 메인넷이나 다른 곳에서 재전송할 수 있습니다.\n\n## 어떻게 동작하나요?\n\n포크 블록 `N`부터 노드는 체인 ID가 자신의 설정에 있는 체인 ID와 다른 모든 트랜잭션을 거부합니다. 특히 `chainId = 0`인 트랜잭션은 무효가 됩니다.\n\n```text\nif node.config.chainId != tx.chainId:\n    reject(tx)\n```\n\n이 검사는 두 곳에 적용됩니다.\n\n1. **JSON-RPC**(`eth_sendTransaction`, `eth_sendRawTransaction`): 일찍 거부하므로, 실패가 확실한 트랜잭션이 사용자에게 보류 상태로 남는 일이 없습니다.\n2. 블록 처리 중의 **트랜잭션 검증**: 그런 트랜잭션이 블록에 포함될 수 없게 합니다.\n\n노드에 설정된 체인 ID가 유일한 진실의 원천입니다.\n\n## 샘플 코드\n\n타입 트랜잭션([EIP-2718](/eip-2718/), 예: [EIP-1559](/eip-1559/) 타입 2)은 항상 명시적인 `chainId`를 담습니다. ethers v6에서는 서명자가 연결된 provider에서 이를 채워 주며, 의도를 명시적으로 밝힐 수도 있습니다.\n\n```ts\nimport { JsonRpcProvider, Wallet, parseEther } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst wallet = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst { chainId } = await provider.getNetwork();\n\nconst tx = await wallet.sendTransaction({\n  to: \"0x000000000000000000000000000000000000dEaD\",\n  value: parseEther(\"0.001\"),\n  chainId,            // bound to this network only, never 0\n});\nconsole.log(tx.chainId); // e.g. 1n on mainnet\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 네트워크 업그레이드로 예정된 적이 없습니다.\n- 명세는 포크 블록 이후에도 `chainId == 0` 트랜잭션을 계속 제출하는 애플리케이션이나 도구가 깨질 것이라고 말합니다.\n- 누군가 `chainId = 1`이나 다른 기존 ID를 재사용하는 네트워크를 띄우는 것은 막지 못합니다. 리플레이 보호는 체인 ID가 고유할 때만 작동합니다.\n- 지갑에게 실용적인 교훈은 포크 없이도 유효합니다. 항상 명시적이고 올바른 체인 ID로 서명하고 그것을 사용자에게 보여 주세요.\n"},"zh":{"lang":"zh","tldr":"提议让节点拒绝任何 chainId 与自身不一致的交易，堵住 chainId 为 0 的交易可以跨链重放的漏洞。","tags":["transactions","chainid","replay-protection","security","core"],"related":[155,2718,1559],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3788/","markdown":"## 它解决什么问题？\n\n[EIP-155](/eip-155/) 为已签名的交易加入了链 ID，使为某个网络签名的交易无法在另一个网络上重放。但正如这份 EIP 指出的，`chainId = 0` 的交易仍然被视为有效。这是有意保留的，目的是让开发者能够创建在任何链上都能工作的交易。\n\n由于有许多 EVM 兼容网络是由以太坊客户端分叉构建的，这个后门变成了风险。大多数钱包不会向用户显示他们签署的链 ID。恶意（或粗心）的网络可以诱使用户签署 `chainId = 0` 的交易，然后在以太坊主网或其他地方重放它们。\n\n## 它如何运作\n\n从分叉区块 `N` 开始，节点拒绝任何链 ID 与自己配置中的链 ID 不同的交易。特别是，`chainId = 0` 的交易变为无效。\n\n```text\nif node.config.chainId != tx.chainId:\n    reject(tx)\n```\n\n该检查应用于两处：\n\n1. **JSON-RPC**（`eth_sendTransaction`、`eth_sendRawTransaction`）：尽早拒绝，这样用户永远不会有一笔注定失败的交易处于待处理状态。\n2. 区块处理期间的**交易验证**：这样此类交易永远不可能被打包进区块。\n\n节点配置的链 ID 是唯一的事实来源。\n\n## 示例代码\n\n类型化交易（[EIP-2718](/eip-2718/)，例如 [EIP-1559](/eip-1559/) 的类型 2）始终带有显式的 `chainId`。使用 ethers v6 时，签名者会根据所连接的 provider 填入它，你也可以把意图写明：\n\n```ts\nimport { JsonRpcProvider, Wallet, parseEther } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst wallet = new Wallet(process.env.PRIVATE_KEY!, provider);\nconst { chainId } = await provider.getNetwork();\n\nconst tx = await wallet.sendTransaction({\n  to: \"0x000000000000000000000000000000000000dEaD\",\n  value: parseEther(\"0.001\"),\n  chainId,            // bound to this network only, never 0\n});\nconsole.log(tx.chainId); // e.g. 1n on mainnet\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。它从未被排入网络升级。\n- 规范指出，在分叉区块之后，任何仍提交 `chainId == 0` 交易的应用或工具都会被破坏。\n- 它无法阻止有人启动一个复用 `chainId = 1` 或任何其他现有 ID 的网络。只有链 ID 唯一时，重放保护才有效。\n- 对钱包来说，即使没有分叉，实用的教训依然成立：始终使用显式且正确的链 ID 签名，并向用户显示它。\n"}}}
