{"eip":155,"title":"Simple replay attack protection","authors":["Vitalik Buterin (@vbuterin)"],"status":"Final","type":"Standards Track","category":"Core","created":"2016-10-14","repo":"EIPs","label":"EIP-155","officialUrl":"https://eips.ethereum.org/EIPS/eip-155","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md","url":"https://eips.huatuo.xyz/eip-155/","tldr":{"en":"Mixes a chain ID into every transaction signature, so a transaction signed for one Ethereum network cannot be replayed on another.","ja":"すべてのトランザクション署名にチェーン ID を組み込み、ある Ethereum ネットワーク向けに署名したトランザクションを別のネットワークでリプレイできないようにする。","ko":"모든 트랜잭션 서명에 체인 ID를 섞어 넣어, 한 이더리움 네트워크용으로 서명한 트랜잭션을 다른 네트워크에서 재생(replay)할 수 없게 한다.","zh":"将链 ID 混入每笔交易签名，使为某个以太坊网络签名的交易无法在另一个网络上重放。"},"tags":["transactions","signatures","chainid","security","core"],"explainers":{"en":{"lang":"en","tldr":"Mixes a chain ID into every transaction signature, so a transaction signed for one Ethereum network cannot be replayed on another.","tags":["transactions","signatures","chainid","security","core"],"related":[607,2718,1344,695,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-155/","markdown":"## What problem does it solve?\n\nAfter the 2016 DAO fork, Ethereum and Ethereum Classic shared the same history, addresses and transaction format. A transaction signed for one chain was also valid on the other, so anyone could copy it across and \"replay\" it. Users who sent ETH on one chain could lose the matching ETC, and the reverse.\n\nEIP-155 makes signatures chain-specific by including a chain ID in what gets signed. It went live in the Spurious Dragon hard fork ([EIP-607](/eip-607/)) at block 2,675,000. Mainnet's chain ID is `1`.\n\n## How it works\n\nBefore EIP-155, a legacy transaction was signed over six RLP-encoded fields:\n\n```\n(nonce, gasprice, startgas, to, value, data)\n```\n\nWith EIP-155 the signer hashes nine fields instead:\n\n```\n(nonce, gasprice, startgas, to, value, data, chainid, 0, 0)\n```\n\nThe recovery value `v` then encodes the chain ID too:\n\n```\nv = {0,1} + CHAIN_ID * 2 + 35      # protected\nv = {0,1} + 27                     # old, unprotected\n```\n\nwhere `{0,1}` is the parity of the curve point's y-value. On mainnet, protected signatures have `v = 37` or `38`.\n\nWhen a node sees `v = CHAIN_ID * 2 + 35` or `+ 36`, it rebuilds the nine-field hash to recover the sender. A signature made for chain 1 fails to recover the right sender on chain 61, so replay is impossible. Old `v = 27/28` signatures stay valid under the old rules. The scheme is opt-in at the protocol level.\n\n## Sample code\n\nThe spec's worked example: nonce 9, gas price 20 gwei, gas 21000, sending 1 ETH to `0x3535…3535` on chain 1. The signing payload ends in `018080` (chainid 1, then two empty fields), and the resulting signature has `v = 37`.\n\nSigning a legacy transaction with ethers v6. The chain ID goes into the signature automatically:\n\n```ts\nimport { Wallet, Transaction, parseUnits, parseEther } from \"ethers\";\n\nconst wallet = new Wallet(process.env.PRIVATE_KEY!);\n\nconst signed = await wallet.signTransaction({\n  type: 0,                     // legacy transaction\n  chainId: 1,                  // EIP-155 chain id\n  nonce: 9,\n  gasPrice: parseUnits(\"20\", \"gwei\"),\n  gasLimit: 21000,\n  to: \"0x3535353535353535353535353535353535353535\",\n  value: parseEther(\"1\"),\n});\n\nconst tx = Transaction.from(signed);\nconsole.log(tx.chainId, tx.signature!.networkV); // 1n, 37n or 38n\n```\n\n## Things to know\n\n- Typed transactions ([EIP-2718](/eip-2718/) onwards, including EIP-1559 type-2) carry `chainId` as an explicit field and use a plain `yParity` of 0 or 1. The `v = chainId * 2 + 35` trick only applies to legacy transactions.\n- Unprotected (pre-155) transactions are still valid on-chain. Many node configurations refuse to accept them over RPC by default.\n- Contracts can read the current chain ID with the `CHAINID` opcode ([EIP-1344](/eip-1344/)), and wallets can query it with `eth_chainId` ([EIP-695](/eip-695/)). Off-chain signatures use the same ID through the [EIP-712](/eip-712/) domain.\n- Chain IDs are not assigned by this EIP. Each network picks a unique one, tracked in the community `ethereum-lists/chains` registry.\n- This EIP is Final.\n"},"ja":{"lang":"ja","tldr":"すべてのトランザクション署名にチェーン ID を組み込み、ある Ethereum ネットワーク向けに署名したトランザクションを別のネットワークでリプレイできないようにする。","tags":["transactions","signatures","chainid","security","core"],"related":[607,2718,1344,695,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-155/","markdown":"## 何を解決するのか\n\n2016 年の DAO フォークの後、Ethereum と Ethereum Classic は同じ履歴、アドレス、トランザクション形式を共有していました。一方のチェーン向けに署名したトランザクションは他方でも有効だったため、誰でもそれをコピーして「リプレイ」できました。一方のチェーンで ETH を送ったユーザーが、対応する ETC を失う可能性があり、その逆も起こり得ました。\n\nEIP-155 は、署名対象にチェーン ID を含めることで、署名をチェーン固有のものにします。Spurious Dragon ハードフォーク（[EIP-607](/eip-607/)）のブロック 2,675,000 で有効になりました。メインネットのチェーン ID は `1` です。\n\n## 仕組み\n\nEIP-155 以前、レガシートランザクションは RLP エンコードされた 6 つのフィールドに対して署名されていました。\n\n```\n(nonce, gasprice, startgas, to, value, data)\n```\n\nEIP-155 では、署名者は代わりに 9 つのフィールドをハッシュします。\n\n```\n(nonce, gasprice, startgas, to, value, data, chainid, 0, 0)\n```\n\nリカバリー値 `v` にもチェーン ID が含まれるようになります。\n\n```\nv = {0,1} + CHAIN_ID * 2 + 35      # protected\nv = {0,1} + 27                     # old, unprotected\n```\n\nここで `{0,1}` は曲線上の点の y 値のパリティです。メインネットでは、保護された署名の `v` は `37` または `38` になります。\n\nノードは `v = CHAIN_ID * 2 + 35` または `+ 36` を見ると、9 フィールドのハッシュを再構築して送信者を復元します。チェーン 1 向けに作られた署名は、チェーン 61 では正しい送信者を復元できないため、リプレイは不可能です。従来の `v = 27/28` の署名は、古いルールのもとで引き続き有効です。この方式はプロトコルレベルではオプトインです。\n\n## サンプルコード\n\n仕様の具体例: nonce 9、ガス価格 20 gwei、ガス 21000、チェーン 1 で `0x3535…3535` へ 1 ETH を送信。署名ペイロードは `018080`（チェーン ID の 1、続いて 2 つの空フィールド）で終わり、得られる署名は `v = 37` になります。\n\nethers v6 でレガシートランザクションに署名する例。チェーン ID は自動的に署名へ含まれます。\n\n```ts\nimport { Wallet, Transaction, parseUnits, parseEther } from \"ethers\";\n\nconst wallet = new Wallet(process.env.PRIVATE_KEY!);\n\nconst signed = await wallet.signTransaction({\n  type: 0,                     // legacy transaction\n  chainId: 1,                  // EIP-155 chain id\n  nonce: 9,\n  gasPrice: parseUnits(\"20\", \"gwei\"),\n  gasLimit: 21000,\n  to: \"0x3535353535353535353535353535353535353535\",\n  value: parseEther(\"1\"),\n});\n\nconst tx = Transaction.from(signed);\nconsole.log(tx.chainId, tx.signature!.networkV); // 1n, 37n or 38n\n```\n\n## 知っておくべきこと\n\n- Typed トランザクション（[EIP-2718](/eip-2718/) 以降。EIP-1559 の type-2 を含む）は `chainId` を明示的なフィールドとして持ち、単純な 0 または 1 の `yParity` を使います。`v = chainId * 2 + 35` という仕組みはレガシートランザクションにのみ適用されます。\n- 保護されていない（155 以前の）トランザクションも、オンチェーンでは引き続き有効です。多くのノード構成では、RPC 経由でこれらを受け付けないのがデフォルトです。\n- コントラクトは `CHAINID` opcode（[EIP-1344](/eip-1344/)）で現在のチェーン ID を読み取れ、ウォレットは `eth_chainId`（[EIP-695](/eip-695/)）で取得できます。オフチェーン署名も [EIP-712](/eip-712/) のドメインを通じて同じ ID を使います。\n- チェーン ID はこの EIP が割り当てるものではありません。各ネットワークが一意のものを選び、コミュニティの `ethereum-lists/chains` レジストリで管理されています。\n- この EIP は Final です。\n"},"ko":{"lang":"ko","tldr":"모든 트랜잭션 서명에 체인 ID를 섞어 넣어, 한 이더리움 네트워크용으로 서명한 트랜잭션을 다른 네트워크에서 재생(replay)할 수 없게 한다.","tags":["transactions","signatures","chainid","security","core"],"related":[607,2718,1344,695,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-155/","markdown":"## 어떤 문제를 해결하나요?\n\n2016년 DAO 포크 이후 이더리움과 이더리움 클래식은 같은 이력, 주소, 트랜잭션 형식을 공유했습니다. 한 체인용으로 서명한 트랜잭션이 다른 체인에서도 유효했기 때문에, 누구나 이를 복사해 \"재생\"할 수 있었습니다. 한 체인에서 ETH를 보낸 사용자가 대응하는 ETC를 잃을 수 있었고, 그 반대도 마찬가지였습니다.\n\nEIP-155는 서명 대상에 체인 ID를 포함해 서명을 체인별로 고유하게 만듭니다. 스퓨리어스 드래곤 하드포크([EIP-607](/eip-607/))의 블록 2,675,000에서 적용되었습니다. 메인넷의 체인 ID는 `1`입니다.\n\n## 어떻게 동작하나요?\n\nEIP-155 이전에는 레거시 트랜잭션이 RLP로 인코딩된 여섯 개 필드에 대해 서명되었습니다.\n\n```\n(nonce, gasprice, startgas, to, value, data)\n```\n\nEIP-155에서는 서명자가 대신 아홉 개 필드를 해시합니다.\n\n```\n(nonce, gasprice, startgas, to, value, data, chainid, 0, 0)\n```\n\n복구 값 `v`에도 체인 ID가 인코딩됩니다.\n\n```\nv = {0,1} + CHAIN_ID * 2 + 35      # protected\nv = {0,1} + 27                     # old, unprotected\n```\n\n여기서 `{0,1}`은 곡선 위 점의 y 값의 홀짝(parity)입니다. 메인넷에서 보호된 서명의 `v`는 `37` 또는 `38`입니다.\n\n노드는 `v = CHAIN_ID * 2 + 35` 또는 `+ 36`을 보면 아홉 개 필드의 해시를 재구성해 발신자를 복구합니다. 체인 1용으로 만든 서명은 체인 61에서 올바른 발신자를 복구하지 못하므로 재생이 불가능합니다. 예전의 `v = 27/28` 서명은 옛 규칙에서 계속 유효합니다. 이 방식은 프로토콜 수준에서 선택적(opt-in)입니다.\n\n## 샘플 코드\n\n명세의 실제 예시: nonce 9, 가스 가격 20 gwei, 가스 21000, 체인 1에서 `0x3535…3535`로 1 ETH 전송. 서명 페이로드는 `018080`(체인 ID 1, 이어서 빈 필드 두 개)으로 끝나며, 결과 서명은 `v = 37`입니다.\n\nethers v6로 레거시 트랜잭션에 서명하기. 체인 ID는 서명에 자동으로 들어갑니다.\n\n```ts\nimport { Wallet, Transaction, parseUnits, parseEther } from \"ethers\";\n\nconst wallet = new Wallet(process.env.PRIVATE_KEY!);\n\nconst signed = await wallet.signTransaction({\n  type: 0,                     // legacy transaction\n  chainId: 1,                  // EIP-155 chain id\n  nonce: 9,\n  gasPrice: parseUnits(\"20\", \"gwei\"),\n  gasLimit: 21000,\n  to: \"0x3535353535353535353535353535353535353535\",\n  value: parseEther(\"1\"),\n});\n\nconst tx = Transaction.from(signed);\nconsole.log(tx.chainId, tx.signature!.networkV); // 1n, 37n or 38n\n```\n\n## 알아둘 점\n\n- 타입이 지정된 트랜잭션([EIP-2718](/eip-2718/) 이후, EIP-1559의 type-2 포함)은 `chainId`를 명시적인 필드로 담고, 0 또는 1의 단순한 `yParity`를 사용합니다. `v = chainId * 2 + 35` 방식은 레거시 트랜잭션에만 적용됩니다.\n- 보호되지 않은(155 이전) 트랜잭션도 온체인에서는 여전히 유효합니다. 많은 노드 설정은 기본적으로 RPC를 통한 이런 트랜잭션 수신을 거부합니다.\n- 컨트랙트는 `CHAINID` opcode([EIP-1344](/eip-1344/))로 현재 체인 ID를 읽을 수 있고, 지갑은 `eth_chainId`([EIP-695](/eip-695/))로 조회할 수 있습니다. 오프체인 서명도 [EIP-712](/eip-712/) 도메인을 통해 같은 ID를 사용합니다.\n- 체인 ID는 이 EIP가 할당하지 않습니다. 각 네트워크가 고유한 값을 고르며, 커뮤니티의 `ethereum-lists/chains` 레지스트리에서 관리됩니다.\n- 이 EIP는 Final입니다.\n"},"zh":{"lang":"zh","tldr":"将链 ID 混入每笔交易签名，使为某个以太坊网络签名的交易无法在另一个网络上重放。","tags":["transactions","signatures","chainid","security","core"],"related":[607,2718,1344,695,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-155/","markdown":"## 它解决什么问题？\n\n2016 年 DAO 分叉之后，以太坊和以太坊经典共享相同的历史、地址和交易格式。为一条链签名的交易在另一条链上同样有效，因此任何人都可以把它复制过去并“重放”。在一条链上发送了 ETH 的用户，可能会损失对应的 ETC，反过来也一样。\n\nEIP-155 通过把链 ID 纳入被签名的内容，使签名只对特定链有效。它随 Spurious Dragon 硬分叉（[EIP-607](/eip-607/)）在区块 2,675,000 上线。主网的链 ID 是 `1`。\n\n## 它如何运作\n\n在 EIP-155 之前，传统交易对六个经 RLP 编码的字段进行签名：\n\n```\n(nonce, gasprice, startgas, to, value, data)\n```\n\n有了 EIP-155，签名者改为对九个字段求哈希：\n\n```\n(nonce, gasprice, startgas, to, value, data, chainid, 0, 0)\n```\n\n恢复值 `v` 也随之编码了链 ID：\n\n```\nv = {0,1} + CHAIN_ID * 2 + 35      # protected\nv = {0,1} + 27                     # old, unprotected\n```\n\n其中 `{0,1}` 是曲线上点的 y 值的奇偶性。在主网上，受保护签名的 `v` 为 `37` 或 `38`。\n\n当节点看到 `v = CHAIN_ID * 2 + 35` 或 `+ 36` 时，会重建九字段哈希来恢复发送者。为链 1 生成的签名在链 61 上无法恢复出正确的发送者，因此无法重放。旧的 `v = 27/28` 签名在旧规则下依然有效。该方案在协议层面是可选启用的。\n\n## 示例代码\n\n规范中的完整示例：nonce 9、gas 价格 20 gwei、gas 21000，在链 1 上向 `0x3535…3535` 发送 1 ETH。签名载荷以 `018080`（链 ID 1，后跟两个空字段）结尾，得到的签名 `v = 37`。\n\n使用 ethers v6 对传统交易签名。链 ID 会自动写入签名：\n\n```ts\nimport { Wallet, Transaction, parseUnits, parseEther } from \"ethers\";\n\nconst wallet = new Wallet(process.env.PRIVATE_KEY!);\n\nconst signed = await wallet.signTransaction({\n  type: 0,                     // legacy transaction\n  chainId: 1,                  // EIP-155 chain id\n  nonce: 9,\n  gasPrice: parseUnits(\"20\", \"gwei\"),\n  gasLimit: 21000,\n  to: \"0x3535353535353535353535353535353535353535\",\n  value: parseEther(\"1\"),\n});\n\nconst tx = Transaction.from(signed);\nconsole.log(tx.chainId, tx.signature!.networkV); // 1n, 37n or 38n\n```\n\n## 需要注意\n\n- 类型化交易（[EIP-2718](/eip-2718/) 及之后，包括 EIP-1559 的 type-2）把 `chainId` 作为显式字段，并使用取值为 0 或 1 的普通 `yParity`。`v = chainId * 2 + 35` 这一做法只适用于传统交易。\n- 未受保护的（155 之前的）交易在链上依然有效。许多节点配置默认拒绝通过 RPC 接收它们。\n- 合约可以用 `CHAINID` opcode（[EIP-1344](/eip-1344/)）读取当前链 ID，钱包可以用 `eth_chainId`（[EIP-695](/eip-695/)）查询。链下签名通过 [EIP-712](/eip-712/) 域使用同一个 ID。\n- 链 ID 并非由本 EIP 分配。每个网络自行选择唯一的链 ID，并记录在社区维护的 `ethereum-lists/chains` 注册表中。\n- 该 EIP 状态为 Final。\n"}},"requiredBy":[607,695,712,1191,1193,1344,1710,1959,1965,2015,2193,2256,2294,2400,2972,3074,3085,3326,3788,4361,5081,5139,5267,5375,6404,6734,7015,7700,7730,7769,7811,7828,7831,7946,7950,8004,8100,8126,8196,8202,8410]}
