---
eip: 2488
label: EIP-2488
title: Deprecate the CALLCODE opcode
status: Stagnant
type: Standards Track
category: Core
created: 2019-12-20
requires: 7
official: https://eips.ethereum.org/EIPS/eip-2488
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2488.md
canonical: https://eips.huatuo.xyz/eip-2488/
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]
---

# EIP-2488: Deprecate the CALLCODE opcode

> Deprecate CALLCODE in a somewhat backwards compatible way, by making it always return failure.

**TL;DR:** Proposes switching off the legacy CALLCODE opcode by making it always return failure, removing a feature that was superseded by DELEGATECALL in 2016.

## What problem does it solve?

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

[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.

## How it works

The specification is one line. After a fork block:

- Executing `CALLCODE` always pushes `0` onto the stack, which signals a failed call.

The 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.

The 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.

## Sample code

Illustrative pseudocode for the proposed rule:

```python
def op_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len):
    if evm.block_number >= FORK_BLOCK:
        evm.stack.push(0)   # always "call failed"
        return
    legacy_callcode(evm, gas, addr, value, in_off, in_len, out_off, out_len)
```

What contracts should use instead, `DELEGATECALL` via Solidity:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Caller {
    uint256 public x;

    // Runs `lib`'s code against this contract's storage, keeping msg.sender
    function useLib(address lib, bytes calldata data) external {
        (bool ok, ) = lib.delegatecall(data);
        require(ok, "delegatecall failed");
    }
}
```

## Things to know

- Status is **Stagnant**. It has not been scheduled, and `CALLCODE` still works on Ethereum mainnet today.
- 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".
- Modern Solidity does not expose `callcode`; use `delegatecall`.
- 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.


---

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