---
eip: 7620
label: EIP-7620
title: EOF Contract Creation
status: Stagnant
type: Standards Track
category: Core
created: 2024-02-12
requires: 170, 684, 2929, 3540, 3541, 3670
official: https://eips.ethereum.org/EIPS/eip-7620
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7620.md
canonical: https://eips.huatuo.xyz/eip-7620/
lang: en
tldr: "Part of the EVM Object Format (EOF) upgrade: adds EOFCREATE and RETURNCODE so EOF factory contracts can deploy child contracts from embedded subcontainers, replacing CREATE/CREATE2 inside EOF code."
tags: [evm, eof, opcodes, contract-creation, core]
---

# EIP-7620: EOF Contract Creation

> Introduce `EOFCREATE` and `RETURNCODE` instructions

**TL;DR:** Part of the EVM Object Format (EOF) upgrade: adds EOFCREATE and RETURNCODE so EOF factory contracts can deploy child contracts from embedded subcontainers, replacing CREATE/CREATE2 inside EOF code.

## What problem does it solve?

The EVM Object Format (EOF, [EIP-3540](/eip-3540/)) is a proposed structured container for contract bytecode, with separate code and data sections and validation at deploy time. A core EOF goal is **code non-observability**: contracts should not be able to read or manipulate code as data. That rules out the legacy creation path, where `CREATE`/`CREATE2` take arbitrary bytes from memory (often built with `CODECOPY`) and execute them as initcode.

Factories still need to deploy contracts, though. EIP-7620 gives EOF its own creation mechanism: the code to be deployed is embedded, already validated, as a **subcontainer** of the factory, and new instructions select it by index.

## How it works

Two new opcodes, valid only inside EOF code:

**`EOFCREATE` (`0xec`)**, with a 1-byte immediate `initcontainer_index`:

- Pops `salt, input_offset, input_size, value` (order aligned with `EXTCALL`, see [EIP-7069](/eip-7069/)).
- Charges 32,000 gas, fails in static context, checks call depth and balance.
- Runs subcontainer `initcontainer_index` as initcode, with the memory slice as its calldata.
- New address is `keccak256(0xff || sender32 || salt)[12:]`. Unlike [CREATE2](/eip-1014/), the initcode hash is **not** included, so the address depends only on deployer and salt.
- Pushes the new address on success, `0` on failure; charges 200 gas per deployed byte.

**`RETURNCODE` (`0xee`)**, with a 1-byte immediate `deploy_container_index`:

- Ends the initcode frame and names which subcontainer becomes the runtime code.
- Pops `aux_data_offset, aux_data_size`; that memory is **appended to the deployed container's data section**. This is how constructor arguments and immutables get baked in without patching code.

Validation rules make sure container indices exist, that a subcontainer is used either as initcode or as runtime code but not both, and that initcode ends with `RETURNCODE` rather than `RETURN`/`STOP`.

In EOF code, `CREATE` and `CREATE2` are rejected. In legacy code, `CREATE`/`CREATE2` with initcode starting `0xEF00` fail early without consuming the initcode's gas. Top-level deployment from a transaction is handled separately by [EIP-7873](/eip-7873/).

## Sample code

Pseudocode for the core of `EOFCREATE`:

```python
def eofcreate(frame, initcontainer_index):
    charge_gas(frame, 32000)
    assert not frame.is_static
    salt, in_off, in_size, value = frame.stack.pop_n(4)
    expand_memory(frame, in_off, in_size)

    init = frame.container.subcontainers[initcontainer_index]
    if frame.depth >= 1024 or frame.balance < value:
        frame.stack.push(0); return

    result = execute(init, calldata=frame.memory[in_off:in_off + in_size], value=value)
    frame.sender.nonce += 1
    new_address = keccak256(b"\xff" + frame.address.rjust(32, b"\0") + salt)[12:]

    if not result.success:
        frame.stack.push(0); return
    deployed = result.deploy_container.with_appended_data(result.aux_data)
    assert len(deployed) <= 24576
    set_code(new_address, deployed)
    charge_gas(frame, 200 * len(deployed))
    frame.stack.push(new_address)
```

## Things to know

- Status is **Stagnant**. EOF as a whole (meta EIP [EIP-7692](/eip-7692/)) has not been activated on Ethereum mainnet, and the related EOF EIPs are Stagnant as well.
- Factories wanting to commit to the exact child code can fold its hash into `salt` themselves, since the address formula leaves it out.
- `EOFCREATE` and `RETURNCODE` in legacy bytecode are invalid and halt, so nothing changes for non-EOF contracts.
- The main security review burden sits with [EIP-7873](/eip-7873/)'s initcode transactions, where new unverified code enters the state.


---

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