EIP-7880 The EOF EXTCODEADDRESS opcode (EOF - EXTCODEADDRESS instruction)
No call decision · EVM & execution · EIP status Review · created 2025-02-08
Adds a new opcode, EXTCODEADDRESS (0xea), that lets an EOF contract obtain the actual target address of an EIP-7702 delegation without directly reading another account's code. If there is no delegation, the queried address is returned as is.
Why it is needed
EOF (EVM Object Format) is a new code format for the Ethereum Virtual Machine. EOFv1, within the scope of EIP-7692, removed the ability for contracts to directly read another account's code bytes (code introspection). However, EIP-7702 lets a regular user account record a marker (a delegation designation) in its code slot indicating that execution is delegated to a specific contract. An EOF contract that cannot read code also cannot read this marker. The source cites cases where this becomes a problem. A managed proxy wants to ensure safety by preventing the proxy from being updated to a delegated address. A gas sponsorship service, after granting approval, needs to verify that the delegation written in the transaction data matches the actual delegation, to prevent the delegation from being changed afterward to perform an action different from what was approved. A contract that wants to allow only a small whitelist of delegations in order to reduce risk needs to know not just whether a delegation exists but the actual delegated address. This EIP hands off the job of interpreting the delegation designation to the new EXTCODEADDRESS opcode, allowing the delegated address to be obtained without directly reading the code.
What changes
Today
- An EOF contract cannot read another account's code bytes, so it cannot tell whether or to where an EIP-7702 delegation points
- A managed proxy has no way to check whether a new implementation address is a delegated account
- A gas sponsorship service has difficulty verifying that the delegation at approval time matches the delegation at execution time
After EIP-7880
- A single EXTCODEADDRESS call directly returns the actual delegated address
- For accounts with no delegation, or empty accounts, the queried address is returned as is
- Since the code bytes themselves are not exposed, existing code will not break even if the delegation designation format changes in the future
Who is affected
- EOF contract developers: Logic that directly checks the delegated address can be added for patterns like managed proxies, gas sponsorship, and delegation whitelists
- Gas sponsorship services: By recording the delegation address in the transaction data and verifying it matches at execution time, transactions that act differently from what was approved can be filtered out
- Client teams: The 0xea opcode and its gas rules must be implemented in EOFv1 validators and interpreters
- Users of EIP-7702 accounts: Not a feature used directly, but as more contracts check delegation status, more safeguards appear in advance against user experience problems when using delegated accounts
In depth
New opcode EXTCODEADDRESS (0xea)
This adds the EXTCODEADDRESS opcode to EOFv1 as opcode 0xea. Before the fork that activates this EIP, EOF code containing 0xea is treated as invalid during validation. From the first block at which it is activated, 0xea becomes part of the valid EOFv1 opcode set. It pops one target_address from the stack and pushes one resolved address onto the stack, depending on whether delegation applies. It does not bump the EOF version.
Execution procedure and gas
First it deducts GAS_WARM_ACCESS (100) gas and pops target_address from the stack. If any of the upper 12 bytes is nonzero, i.e. it is not a 20-byte address, execution aborts with an exception. However, the source text notes that if the EVM address space is expanded in the future, the valid address range could grow larger, so this step should not be assumed to always abort. If target_address is not in accessed_addresses, it additionally deducts GAS_COLD_ACCOUNT_ACCESS (2600) minus GAS_WARM_ACCESS and adds it to the list. It then reads that account's code (loaded_code): if it is an EIP-7702 delegation designation (e.g. the 0xef0100 prefix), it pushes the delegation target address; otherwise it pushes target_address.
Warming rules and edge cases
Only target_address is warmed. Even if a delegation is found, the delegation target address is not added to accessed_addresses, and whether that address is already in the list has no effect on gas. If target_address is queried for a contract that is currently being created, target_address itself is returned; if the delegation designation points to a contract under creation, the delegation target address is returned. The source text explains that this opcode sits between EIP-7702's code-reading family and its code-execution family. Its operational steps behave like a code-reading opcode, but its return value is a resolved address, as with a code-execution opcode. It also notes that if delegation designation changes in a future fork (e.g. allowing chained delegation), this opcode is expected to follow that change.
Design choice: why it returns only an address
As an alternative, a specially restricted EXTCODECOPY approach that returns the entire delegation designation and lets the contract resolve it itself was considered. The source text rejects this. Beyond the general objection to code introspection, that approach would lock in the delegation designation's format and functionality as a constraint that must be preserved in future forks as well. Exposing only the effect rather than the mechanism, i.e. only the resolved address, leaves room to change the mechanism without breaking existing code. The EIP also states that it is very similar to EIP-7761, which introduces account type introspection, and that it draws on that EIP's rationale as a reference.
Backward compatibility
0xea is an opcode that was rejected by EOF validation before this EIP is activated. So no EOF contract on chain contains the 0xea opcode, and no existing contract's behavior changes. This allows it to be introduced while preserving backward compatibility, without bumping the EOFv1 version.
Status and remaining variables
This EIP is in Review status, so the specification may still change. As of the source text's writing, EIP-7702 code delegation is a new feature not yet deployed on mainnet, and the author wrote that they would monitor its progress and reflect any effects on this opcode. The accompanying call notes contain no fork-inclusion decision for this EIP.