{"eip":2488,"title":"Deprecate the CALLCODE opcode","description":"Deprecate CALLCODE in a somewhat backwards compatible way, by making it always return failure.","authors":["Alex Beregszaszi (@axic)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2019-12-20","requires":[7],"discussionsTo":"https://ethereum-magicians.org/t/eip-2488-deprecate-the-callcode-opcode/3957","repo":"EIPs","label":"EIP-2488","officialUrl":"https://eips.ethereum.org/EIPS/eip-2488","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2488.md","url":"https://eips.huatuo.xyz/eip-2488/","tldr":{"en":"Proposes switching off the legacy CALLCODE opcode by making it always return failure, removing a feature that was superseded by DELEGATECALL in 2016.","ja":"レガシーな CALLCODE オペコードを常に失敗を返すようにして無効化することを提案する。2016 年に DELEGATECALL に取って代わられた機能を取り除く。","ko":"레거시 CALLCODE 옵코드가 항상 실패를 반환하도록 만들어 꺼 버리자고 제안한다. 2016년에 DELEGATECALL로 대체된 기능을 제거한다.","zh":"提议让遗留的 CALLCODE 操作码始终返回失败，从而将其关闭，移除这个在 2016 年已被 DELEGATECALL 取代的功能。"},"tags":["evm","opcode","deprecation","core"],"explainers":{"en":{"lang":"en","tldr":"Proposes switching off the legacy CALLCODE opcode by making it always return failure, removing a feature that was superseded by DELEGATECALL in 2016.","tags":["evm","opcode","deprecation","core"],"related":[7,3540,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2488/","markdown":"## What problem does it solve?\n\n`CALLCODE` (`0xf2`) shipped with Frontier. It was meant to let a contract run another contract's code against its own storage, like a library call. In practice it got one thing wrong: inside the borrowed code, `msg.sender` and `msg.value` were not preserved from the original call, which made it awkward to use safely.\n\n[EIP-7](/eip-7/) fixed this in Homestead (early 2016) by adding `DELEGATECALL`, which does preserve the caller context. Since then `CALLCODE` has been effectively unused, but every EVM implementation still has to support it. ERC-2488 proposes retiring it.\n\n## How it works\n\nThe specification is one line. After a fork block:\n\n- Executing `CALLCODE` always pushes `0` onto the stack, which signals a failed call.\n\nThe opcode is not removed and does not abort execution. That is deliberate: by returning failure, a contract that still calls `CALLCODE` gets a chance to notice and recover, instead of reverting outright.\n\nThe spec notes this would not help clients that sync from genesis (they must still execute historical `CALLCODE`s), but would help light clients and clients that start from a later state.\n\n## Sample code\n\nIllustrative pseudocode for the proposed rule:\n\n```python\ndef op_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len):\n    if evm.block_number \u003e= FORK_BLOCK:\n        evm.stack.push(0)   # always \"call failed\"\n        return\n    legacy_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len)\n```\n\nWhat contracts should use instead, `DELEGATECALL` via Solidity:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Caller {\n    uint256 public x;\n\n    // Runs `lib`'s code against this contract's storage, keeping msg.sender\n    function useLib(address lib, bytes calldata data) external {\n        (bool ok, ) = lib.delegatecall(data);\n        require(ok, \"delegatecall failed\");\n    }\n}\n```\n\n## Things to know\n\n- Status is **Stagnant**. It has not been scheduled, and `CALLCODE` still works on Ethereum mainnet today.\n- It is a breaking change. The author expects no valuable contracts to be affected, but the spec itself marks that claim as not yet validated, and security considerations, tests and implementation are left as \"TBA\".\n- Modern Solidity does not expose `callcode`; use `delegatecall`.\n- The EVM Object Format ([EIP-3540](/eip-3540/)) takes a different route: [EIP-3670](/eip-3670/) code validation rejects `CALLCODE` in new EOF contracts, while leaving legacy contracts untouched.\n"},"ja":{"lang":"ja","tldr":"レガシーな CALLCODE オペコードを常に失敗を返すようにして無効化することを提案する。2016 年に DELEGATECALL に取って代わられた機能を取り除く。","tags":["evm","opcode","deprecation","core"],"related":[7,3540,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2488/","markdown":"## 何を解決するのか\n\n`CALLCODE`（`0xf2`）は Frontier で導入されました。あるコントラクトが、別のコントラクトのコードを自身のストレージに対して実行できるようにする、ライブラリ呼び出しのような機能のはずでした。実際には 1 点を誤っていました。借用したコードの中で `msg.sender` と `msg.value` が元の呼び出しから保持されなかったため、安全に使うのが難しかったのです。\n\n[EIP-7](/eip-7/) は Homestead（2016 年初頭）で `DELEGATECALL` を追加してこれを修正しました。`DELEGATECALL` は呼び出し元のコンテキストを保持します。それ以来 `CALLCODE` は事実上使われていませんが、すべての EVM 実装が今もサポートしなければなりません。ERC-2488 はこれを廃止することを提案します。\n\n## 仕組み\n\n仕様は 1 行です。フォークブロックの後:\n\n- `CALLCODE` を実行すると、常にスタックに `0` をプッシュします。これは呼び出しの失敗を示します。\n\nオペコードは削除されず、実行も中断しません。これは意図的です。失敗を返すことで、まだ `CALLCODE` を呼ぶコントラクトは、即座に revert するのではなく、それに気づいて回復する機会を得られます。\n\n仕様は、これがジェネシスから同期するクライアントには役立たない（過去の `CALLCODE` を実行する必要がある）一方、ライトクライアントや後の状態から開始するクライアントには役立つと述べています。\n\n## サンプルコード\n\n提案されたルールを説明する疑似コード:\n\n```python\ndef op_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len):\n    if evm.block_number \u003e= FORK_BLOCK:\n        evm.stack.push(0)   # always \"call failed\"\n        return\n    legacy_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len)\n```\n\nコントラクトが代わりに使うべきもの、Solidity 経由の `DELEGATECALL`:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Caller {\n    uint256 public x;\n\n    // Runs `lib`'s code against this contract's storage, keeping msg.sender\n    function useLib(address lib, bytes calldata data) external {\n        (bool ok, ) = lib.delegatecall(data);\n        require(ok, \"delegatecall failed\");\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。スケジュールされておらず、`CALLCODE` は現在も Ethereum メインネットで動作します。\n- 破壊的変更です。作者は価値のあるコントラクトに影響はないと見込んでいますが、仕様自体がその主張を未検証としており、セキュリティ上の考慮事項、テスト、実装は「TBA」のままです。\n- 現代の Solidity は `callcode` を公開していません。`delegatecall` を使ってください。\n- EVM Object Format（[EIP-3540](/eip-3540/)）は別の道を取ります。[EIP-3670](/eip-3670/) のコード検証は新しい EOF コントラクトでの `CALLCODE` を拒否し、レガシーなコントラクトには手を付けません。\n"},"ko":{"lang":"ko","tldr":"레거시 CALLCODE 옵코드가 항상 실패를 반환하도록 만들어 꺼 버리자고 제안한다. 2016년에 DELEGATECALL로 대체된 기능을 제거한다.","tags":["evm","opcode","deprecation","core"],"related":[7,3540,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2488/","markdown":"## 어떤 문제를 해결하나요?\n\n`CALLCODE`(`0xf2`)는 Frontier와 함께 출시되었습니다. 한 컨트랙트가 다른 컨트랙트의 코드를 자기 스토리지에 대해 실행할 수 있게 하려는, 라이브러리 호출 같은 기능이었습니다. 실제로는 한 가지가 잘못되어 있었습니다. 빌려 온 코드 안에서 `msg.sender`와 `msg.value`가 원래 호출에서 유지되지 않아 안전하게 쓰기 까다로웠습니다.\n\n[EIP-7](/eip-7/)은 Homestead(2016년 초)에서 호출자 컨텍스트를 유지하는 `DELEGATECALL`을 추가해 이를 고쳤습니다. 그 이후 `CALLCODE`는 사실상 쓰이지 않지만, 모든 EVM 구현은 여전히 이를 지원해야 합니다. ERC-2488은 이를 퇴역시키자고 제안합니다.\n\n## 어떻게 동작하나요?\n\n스펙은 한 줄입니다. 포크 블록 이후:\n\n- `CALLCODE`를 실행하면 항상 스택에 `0`을 푸시합니다. 이는 호출 실패를 나타냅니다.\n\n옵코드는 제거되지 않고 실행을 중단시키지도 않습니다. 이는 의도적입니다. 실패를 반환하면 여전히 `CALLCODE`를 호출하는 컨트랙트가 곧바로 revert되는 대신 이를 알아차리고 복구할 기회를 얻습니다.\n\n스펙은 이것이 제네시스부터 동기화하는 클라이언트(과거의 `CALLCODE`를 여전히 실행해야 함)에는 도움이 되지 않지만, 라이트 클라이언트와 더 나중의 상태에서 시작하는 클라이언트에는 도움이 된다고 설명합니다.\n\n## 샘플 코드\n\n제안된 규칙을 보여 주는 설명용 의사 코드:\n\n```python\ndef op_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len):\n    if evm.block_number \u003e= FORK_BLOCK:\n        evm.stack.push(0)   # always \"call failed\"\n        return\n    legacy_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len)\n```\n\n컨트랙트가 대신 사용해야 할 것, Solidity를 통한 `DELEGATECALL`:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Caller {\n    uint256 public x;\n\n    // Runs `lib`'s code against this contract's storage, keeping msg.sender\n    function useLib(address lib, bytes calldata data) external {\n        (bool ok, ) = lib.delegatecall(data);\n        require(ok, \"delegatecall failed\");\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. 일정이 잡히지 않았으며 `CALLCODE`는 현재 이더리움 메인넷에서 여전히 동작합니다.\n- 하위 호환이 깨지는 변경입니다. 작성자는 가치 있는 컨트랙트가 영향을 받지 않으리라 예상하지만, 스펙 자체가 그 주장을 아직 검증되지 않은 것으로 표시하고 있으며 보안 고려 사항, 테스트, 구현은 \"TBA\"로 남아 있습니다.\n- 현대의 Solidity는 `callcode`를 노출하지 않습니다. `delegatecall`을 사용하세요.\n- EVM 오브젝트 포맷([EIP-3540](/eip-3540/))은 다른 길을 갑니다. [EIP-3670](/eip-3670/)의 코드 검증은 새 EOF 컨트랙트에서 `CALLCODE`를 거부하되 레거시 컨트랙트는 건드리지 않습니다.\n"},"zh":{"lang":"zh","tldr":"提议让遗留的 CALLCODE 操作码始终返回失败，从而将其关闭，移除这个在 2016 年已被 DELEGATECALL 取代的功能。","tags":["evm","opcode","deprecation","core"],"related":[7,3540,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2488/","markdown":"## 它解决什么问题？\n\n`CALLCODE`（`0xf2`）随 Frontier 发布。它本意是让一个合约针对自己的存储运行另一个合约的代码，类似库调用。实际上它有一处设计错误：在借来的代码内部，`msg.sender` 和 `msg.value` 没有从原始调用中保留下来，导致很难安全地使用。\n\n[EIP-7](/eip-7/) 在 Homestead（2016 年初）中通过加入 `DELEGATECALL` 修复了这一问题，它确实保留了调用者上下文。从那以后，`CALLCODE` 实际上无人使用，但每个 EVM 实现仍然必须支持它。ERC-2488 提议将其退役。\n\n## 它如何运作\n\n规范只有一行。在分叉区块之后：\n\n- 执行 `CALLCODE` 始终向栈中压入 `0`，表示调用失败。\n\n该操作码并未被移除，也不会中止执行。这是有意为之：通过返回失败，仍在调用 `CALLCODE` 的合约有机会发现并恢复，而不是直接回滚。\n\n规范指出，这对从创世区块开始同步的客户端没有帮助（它们仍须执行历史上的 `CALLCODE`），但对轻客户端和从较晚状态开始的客户端有帮助。\n\n## 示例代码\n\n对所提议规则的示意性伪代码：\n\n```python\ndef op_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len):\n    if evm.block_number \u003e= FORK_BLOCK:\n        evm.stack.push(0)   # always \"call failed\"\n        return\n    legacy_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len)\n```\n\n合约应改用的方案，即通过 Solidity 使用 `DELEGATECALL`：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Caller {\n    uint256 public x;\n\n    // Runs `lib`'s code against this contract's storage, keeping msg.sender\n    function useLib(address lib, bytes calldata data) external {\n        (bool ok, ) = lib.delegatecall(data);\n        require(ok, \"delegatecall failed\");\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。它尚未排期，`CALLCODE` 目前在以太坊主网上仍然可用。\n- 这是一项破坏性变更。作者预计不会影响任何有价值的合约，但规范本身也标明这一说法尚未验证，安全性考虑、测试和实现均留作\"TBA\"。\n- 现代 Solidity 不再暴露 `callcode`；请使用 `delegatecall`。\n- EVM 对象格式（[EIP-3540](/eip-3540/)）走了另一条路：[EIP-3670](/eip-3670/) 的代码验证会拒绝新的 EOF 合约中的 `CALLCODE`，同时不触动遗留合约。\n"}}}
