EIPs Explained

EIP-7880 · Review · Core · 2025-02-08

EIP-7880: EOF - EXTCODEADDRESS instruction

Adds an EXTCODEADDRESS opcode to EOF so contracts can learn where an EIP-7702 delegated account actually points, without reintroducing code introspection.

What problem does it solve?

EIP-7702 lets an EOA install a delegation designator: a short piece of "code" (0xef0100 followed by an address) that makes calls to the account run another contract's code. Legacy contracts can spot this by reading the account's code with EXTCODECOPY.

EOF (EIP-7692) deliberately removes code introspection, so EOF contracts cannot read raw code at all, and therefore cannot tell where an account delegates to. That matters for a few real use cases:

  • A managed proxy may want to refuse being pointed at a delegated account, whose target could later change to non-EOF code that EXTDELEGATECALL cannot call.
  • A gas sponsor may want to check that an account's delegation did not change between approval and execution.
  • A contract may want to accept only a small allow-list of delegation targets.

How it works

The EIP adds one EOFv1 instruction, EXTCODEADDRESS at opcode 0xea:

  1. Charge the warm access cost (100 gas).
  2. Pop target_address. If any of the high 12 bytes are non-zero, halt with an exceptional failure.
  3. If the address is cold, charge the extra cold cost (2600 − 100) and mark it warm.
  4. Load the account's code. If it is a delegation designator, push the delegated-to address. Otherwise push target_address itself.

So for a plain EOA, an empty account or a normal contract, the result equals the input; for a delegated EOA it is the delegation target. Only target_address is warmed; the delegated-to address is not added to the access list and does not affect gas.

The design returns the effect of the delegation (an address) rather than the raw designator bytes. That keeps EOF free of code introspection and leaves room to change the designator format in later forks, which the instruction is expected to follow.

Sample code

Pseudocode for the instruction's semantics:

def extcodeaddress(evm):
    charge(evm, GAS_WARM_ACCESS)              # 100
    target = evm.stack.pop()
    if target >> 160 != 0:
        raise ExceptionalHalt
    if target not in evm.accessed_addresses:
        charge(evm, GAS_COLD_ACCOUNT_ACCESS - GAS_WARM_ACCESS)  # +2500
        evm.accessed_addresses.add(target)
    code = get_account(evm.state, target).code
    if code[:3] == b"\xef\x01\x00":         # EIP-7702 delegation designator
        evm.stack.push(int.from_bytes(code[3:23], "big"))
    else:
        evm.stack.push(target)

A sponsor-style check, expressed as contract logic:

expected = calldata.delegate          // signed off-chain by the sponsor
actual   = EXTCODEADDRESS(user)
require(actual == expected)           // delegation unchanged since approval

Things to know

  • Status is Review. It depends on EOF (EIP-7692), which is Stagnant in data/eips.json, so this opcode is not on a mainnet schedule.
  • It is a sibling of EIP-7761 (EXTCODETYPE), which reports what kind of account an address is; this one reports where it delegates.
  • Adding 0xea needs no EOF version bump: EOF validation rejected that byte before activation, so no deployed EOF code changes behavior.
  • Do not rely on the high-bytes check always halting; the spec notes a future address-space expansion could relax it.

#evm #eof #opcode #eip-7702 #delegation

Details

Authors
Danno Ferrin (@shemnon)
Status
Review
Type
Standards Track / Core
Created
2025-02-08
Requires

Machine-readable: Markdown · JSON