{"eip":7620,"title":"EOF Contract Creation","description":"Introduce `EOFCREATE` and `RETURNCODE` instructions","authors":["Alex Beregszaszi (@axic)","Paweł Bylica (@chfast)","Andrei Maiboroda (@gumb0)","Piotr Dobaczewski (@pdobacz)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2024-02-12","requires":[170,684,2929,3540,3541,3670],"discussionsTo":"https://ethereum-magicians.org/t/eip-7620-eof-contract-creation-instructions/18625","repo":"EIPs","label":"EIP-7620","officialUrl":"https://eips.ethereum.org/EIPS/eip-7620","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7620.md","url":"https://eips.huatuo.xyz/eip-7620/","tldr":{"en":"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.","ja":"EVM Object Format（EOF）アップグレードの一部。EOFCREATE と RETURNCODE を追加し、EOF のファクトリーコントラクトが埋め込まれたサブコンテナから子コントラクトをデプロイできるようにして、EOF コード内の CREATE/CREATE2 に置き換わる。","ko":"EVM Object Format(EOF) 업그레이드의 일부. EOFCREATE와 RETURNCODE를 추가하여 EOF 팩토리 컨트랙트가 내장된 서브컨테이너에서 자식 컨트랙트를 배포할 수 있게 하고, EOF 코드 안의 CREATE/CREATE2를 대체한다.","zh":"EVM 对象格式（EOF）升级的一部分：新增 EOFCREATE 和 RETURNCODE，使 EOF 工厂合约可以从内嵌的子容器部署子合约，取代 EOF 代码中的 CREATE/CREATE2。"},"tags":["evm","eof","opcodes","contract-creation","core"],"explainers":{"en":{"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"],"related":[3540,7692,7873,1014,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7620/","markdown":"## What problem does it solve?\n\nThe 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.\n\nFactories 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.\n\n## How it works\n\nTwo new opcodes, valid only inside EOF code:\n\n**`EOFCREATE` (`0xec`)**, with a 1-byte immediate `initcontainer_index`:\n\n- Pops `salt, input_offset, input_size, value` (order aligned with `EXTCALL`, see [EIP-7069](/eip-7069/)).\n- Charges 32,000 gas, fails in static context, checks call depth and balance.\n- Runs subcontainer `initcontainer_index` as initcode, with the memory slice as its calldata.\n- 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.\n- Pushes the new address on success, `0` on failure; charges 200 gas per deployed byte.\n\n**`RETURNCODE` (`0xee`)**, with a 1-byte immediate `deploy_container_index`:\n\n- Ends the initcode frame and names which subcontainer becomes the runtime code.\n- 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.\n\nValidation 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`.\n\nIn 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/).\n\n## Sample code\n\nPseudocode for the core of `EOFCREATE`:\n\n```python\ndef eofcreate(frame, initcontainer_index):\n    charge_gas(frame, 32000)\n    assert not frame.is_static\n    salt, in_off, in_size, value = frame.stack.pop_n(4)\n    expand_memory(frame, in_off, in_size)\n\n    init = frame.container.subcontainers[initcontainer_index]\n    if frame.depth \u003e= 1024 or frame.balance \u003c value:\n        frame.stack.push(0); return\n\n    result = execute(init, calldata=frame.memory[in_off:in_off + in_size], value=value)\n    frame.sender.nonce += 1\n    new_address = keccak256(b\"\\xff\" + frame.address.rjust(32, b\"\\0\") + salt)[12:]\n\n    if not result.success:\n        frame.stack.push(0); return\n    deployed = result.deploy_container.with_appended_data(result.aux_data)\n    assert len(deployed) \u003c= 24576\n    set_code(new_address, deployed)\n    charge_gas(frame, 200 * len(deployed))\n    frame.stack.push(new_address)\n```\n\n## Things to know\n\n- 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.\n- Factories wanting to commit to the exact child code can fold its hash into `salt` themselves, since the address formula leaves it out.\n- `EOFCREATE` and `RETURNCODE` in legacy bytecode are invalid and halt, so nothing changes for non-EOF contracts.\n- The main security review burden sits with [EIP-7873](/eip-7873/)'s initcode transactions, where new unverified code enters the state.\n"},"ja":{"lang":"ja","tldr":"EVM Object Format（EOF）アップグレードの一部。EOFCREATE と RETURNCODE を追加し、EOF のファクトリーコントラクトが埋め込まれたサブコンテナから子コントラクトをデプロイできるようにして、EOF コード内の CREATE/CREATE2 に置き換わる。","tags":["evm","eof","opcodes","contract-creation","core"],"related":[3540,7692,7873,1014,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7620/","markdown":"## 何を解決するのか\n\nEVM Object Format（EOF、[EIP-3540](/eip-3540/)）は、コントラクトのバイトコードのための構造化コンテナの提案で、コードセクションとデータセクションが分かれ、デプロイ時に検証されます。EOF の中核的な目標は**コードの非可観測性**です。コントラクトがコードをデータとして読んだり操作したりできてはいけません。そのため、`CREATE`/`CREATE2` がメモリから任意のバイト列（多くは `CODECOPY` で作られる）を取り出して initcode として実行する、従来の生成経路は認められません。\n\nそれでもファクトリーはコントラクトをデプロイする必要があります。EIP-7620 は、EOF 独自の生成メカニズムを与えます。デプロイされるコードは、検証済みのままファクトリーの**サブコンテナ**として埋め込まれ、新しい命令がインデックスでそれを選択します。\n\n## 仕組み\n\nEOF コード内でのみ有効な、2 つの新しい opcode があります。\n\n**`EOFCREATE`（`0xec`）**。1 バイトの即値 `initcontainer_index` を取ります。\n\n- `salt, input_offset, input_size, value` を pop します（順序は `EXTCALL` に合わせています。[EIP-7069](/eip-7069/) を参照）。\n- 32,000 ガスを課し、static コンテキストでは失敗し、コールの深さと残高を確認します。\n- サブコンテナ `initcontainer_index` を initcode として実行し、メモリのスライスを calldata として渡します。\n- 新しいアドレスは `keccak256(0xff || sender32 || salt)[12:]` です。[CREATE2](/eip-1014/) と異なり、initcode のハッシュは含まれ**ない**ため、アドレスはデプロイヤーと salt だけに依存します。\n- 成功すると新しいアドレスを、失敗すると `0` を push します。デプロイされたバイトごとに 200 ガスを課します。\n\n**`RETURNCODE`（`0xee`）**。1 バイトの即値 `deploy_container_index` を取ります。\n\n- initcode のフレームを終了し、どのサブコンテナがランタイムコードになるかを指定します。\n- `aux_data_offset, aux_data_size` を pop します。そのメモリは**デプロイされるコンテナのデータセクションに追記**されます。これにより、コンストラクタ引数や immutable を、コードにパッチを当てずに埋め込めます。\n\n検証ルールにより、コンテナのインデックスが存在すること、サブコンテナが initcode またはランタイムコードのどちらか一方としてのみ使われること、initcode が `RETURN`/`STOP` ではなく `RETURNCODE` で終わることが保証されます。\n\nEOF コードでは `CREATE` と `CREATE2` は拒否されます。従来のコードでは、`0xEF00` で始まる initcode を持つ `CREATE`/`CREATE2` は、initcode のガスを消費せずに早期に失敗します。トランザクションからのトップレベルのデプロイは、[EIP-7873](/eip-7873/) で別途扱われます。\n\n## サンプルコード\n\n`EOFCREATE` の中核部分の擬似コード:\n\n```python\ndef eofcreate(frame, initcontainer_index):\n    charge_gas(frame, 32000)\n    assert not frame.is_static\n    salt, in_off, in_size, value = frame.stack.pop_n(4)\n    expand_memory(frame, in_off, in_size)\n\n    init = frame.container.subcontainers[initcontainer_index]\n    if frame.depth \u003e= 1024 or frame.balance \u003c value:\n        frame.stack.push(0); return\n\n    result = execute(init, calldata=frame.memory[in_off:in_off + in_size], value=value)\n    frame.sender.nonce += 1\n    new_address = keccak256(b\"\\xff\" + frame.address.rjust(32, b\"\\0\") + salt)[12:]\n\n    if not result.success:\n        frame.stack.push(0); return\n    deployed = result.deploy_container.with_appended_data(result.aux_data)\n    assert len(deployed) \u003c= 24576\n    set_code(new_address, deployed)\n    charge_gas(frame, 200 * len(deployed))\n    frame.stack.push(new_address)\n```\n\n## 知っておくべきこと\n\n- ステータスは **Stagnant** です。EOF 全体（メタ EIP の [EIP-7692](/eip-7692/)）は Ethereum メインネットで有効化されておらず、関連する EOF の EIP も Stagnant です。\n- 子コードを正確に固定したいファクトリーは、アドレスの計算式にコードのハッシュが含まれないため、そのハッシュを自分で `salt` に織り込めます。\n- 従来のバイトコードでの `EOFCREATE` と `RETURNCODE` は無効で、実行が停止するため、EOF 以外のコントラクトには何も変わりません。\n- セキュリティレビューの主な負担は、新しい未検証コードがステートに入る [EIP-7873](/eip-7873/) の initcode トランザクションにかかります。\n"},"ko":{"lang":"ko","tldr":"EVM Object Format(EOF) 업그레이드의 일부. EOFCREATE와 RETURNCODE를 추가하여 EOF 팩토리 컨트랙트가 내장된 서브컨테이너에서 자식 컨트랙트를 배포할 수 있게 하고, EOF 코드 안의 CREATE/CREATE2를 대체한다.","tags":["evm","eof","opcodes","contract-creation","core"],"related":[3540,7692,7873,1014,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7620/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM Object Format(EOF, [EIP-3540](/eip-3540/))은 컨트랙트 바이트코드를 위한 구조화된 컨테이너 제안으로, 코드 섹션과 데이터 섹션이 분리되어 있고 배포 시점에 검증됩니다. EOF의 핵심 목표는 **코드 비관측성**입니다. 컨트랙트가 코드를 데이터로 읽거나 조작할 수 없어야 합니다. 그래서 `CREATE`/`CREATE2`가 메모리에서 임의의 바이트(흔히 `CODECOPY`로 만든 것)를 가져와 initcode로 실행하는 기존 생성 경로는 허용되지 않습니다.\n\n하지만 팩토리는 여전히 컨트랙트를 배포해야 합니다. EIP-7620은 EOF에 고유한 생성 메커니즘을 제공합니다. 배포할 코드는 이미 검증된 상태로 팩토리의 **서브컨테이너**로 내장되고, 새 명령어가 인덱스로 이를 선택합니다.\n\n## 어떻게 동작하나요?\n\nEOF 코드 안에서만 유효한 두 개의 새로운 opcode가 있습니다.\n\n**`EOFCREATE`(`0xec`)**, 1바이트 즉시값 `initcontainer_index`를 가집니다.\n\n- `salt, input_offset, input_size, value`를 pop합니다(순서는 `EXTCALL`과 맞춤, [EIP-7069](/eip-7069/) 참고).\n- 32,000 가스를 부과하고, 정적 컨텍스트에서는 실패하며, 호출 깊이와 잔액을 확인합니다.\n- 서브컨테이너 `initcontainer_index`를 initcode로 실행하며 메모리 슬라이스를 calldata로 전달합니다.\n- 새 주소는 `keccak256(0xff || sender32 || salt)[12:]`입니다. [CREATE2](/eip-1014/)와 달리 initcode 해시는 포함되지 **않으므로** 주소는 배포자와 salt에만 의존합니다.\n- 성공하면 새 주소를, 실패하면 `0`을 push하며, 배포된 바이트당 200 가스를 부과합니다.\n\n**`RETURNCODE`(`0xee`)**, 1바이트 즉시값 `deploy_container_index`를 가집니다.\n\n- initcode 프레임을 끝내고 어느 서브컨테이너가 런타임 코드가 될지 지정합니다.\n- `aux_data_offset, aux_data_size`를 pop하며, 해당 메모리는 **배포되는 컨테이너의 데이터 섹션 뒤에 추가**됩니다. 이렇게 해서 생성자 인자와 immutable을 코드를 패치하지 않고 박아 넣을 수 있습니다.\n\n검증 규칙은 컨테이너 인덱스가 존재하는지, 서브컨테이너가 initcode 또는 런타임 코드 중 한쪽으로만 쓰이는지, initcode가 `RETURN`/`STOP`이 아니라 `RETURNCODE`로 끝나는지를 보장합니다.\n\nEOF 코드에서는 `CREATE`와 `CREATE2`가 거부됩니다. 레거시 코드에서는 initcode가 `0xEF00`으로 시작하는 `CREATE`/`CREATE2`가 initcode의 가스를 소비하지 않고 일찍 실패합니다. 트랜잭션에서의 최상위 배포는 [EIP-7873](/eip-7873/)에서 별도로 다룹니다.\n\n## 샘플 코드\n\n`EOFCREATE` 핵심부의 의사 코드:\n\n```python\ndef eofcreate(frame, initcontainer_index):\n    charge_gas(frame, 32000)\n    assert not frame.is_static\n    salt, in_off, in_size, value = frame.stack.pop_n(4)\n    expand_memory(frame, in_off, in_size)\n\n    init = frame.container.subcontainers[initcontainer_index]\n    if frame.depth \u003e= 1024 or frame.balance \u003c value:\n        frame.stack.push(0); return\n\n    result = execute(init, calldata=frame.memory[in_off:in_off + in_size], value=value)\n    frame.sender.nonce += 1\n    new_address = keccak256(b\"\\xff\" + frame.address.rjust(32, b\"\\0\") + salt)[12:]\n\n    if not result.success:\n        frame.stack.push(0); return\n    deployed = result.deploy_container.with_appended_data(result.aux_data)\n    assert len(deployed) \u003c= 24576\n    set_code(new_address, deployed)\n    charge_gas(frame, 200 * len(deployed))\n    frame.stack.push(new_address)\n```\n\n## 알아둘 점\n\n- 상태는 **Stagnant**입니다. EOF 전체(메타 EIP [EIP-7692](/eip-7692/))는 이더리움 메인넷에서 활성화되지 않았고, 관련 EOF EIP들도 Stagnant입니다.\n- 자식 코드를 정확히 고정하고 싶은 팩토리는 주소 공식에 그 해시가 빠져 있으므로 해시를 직접 `salt`에 섞어 넣을 수 있습니다.\n- 레거시 바이트코드의 `EOFCREATE`와 `RETURNCODE`는 유효하지 않아 실행이 중단되므로 EOF가 아닌 컨트랙트에는 아무 변화가 없습니다.\n- 주된 보안 검토 부담은 새로운 미검증 코드가 상태에 들어오는 [EIP-7873](/eip-7873/)의 initcode 트랜잭션에 있습니다.\n"},"zh":{"lang":"zh","tldr":"EVM 对象格式（EOF）升级的一部分：新增 EOFCREATE 和 RETURNCODE，使 EOF 工厂合约可以从内嵌的子容器部署子合约，取代 EOF 代码中的 CREATE/CREATE2。","tags":["evm","eof","opcodes","contract-creation","core"],"related":[3540,7692,7873,1014,3670],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7620/","markdown":"## 它解决什么问题？\n\nEVM 对象格式（EOF，[EIP-3540](/eip-3540/)）是一种面向合约字节码的结构化容器提案，分为独立的代码段和数据段，并在部署时进行验证。EOF 的一个核心目标是**代码不可观测性**：合约不应能够把代码当作数据来读取或操控。这就排除了传统的创建路径，即 `CREATE`/`CREATE2` 从内存中取出任意字节（往往由 `CODECOPY` 构造）并作为 initcode 执行。\n\n不过，工厂仍然需要部署合约。EIP-7620 为 EOF 提供了它自己的创建机制：要部署的代码作为已验证的**子容器**内嵌在工厂中，新指令按索引选择它。\n\n## 它如何运作\n\n两个新的 opcode，仅在 EOF 代码中有效：\n\n**`EOFCREATE`（`0xec`）**，带 1 字节立即数 `initcontainer_index`：\n\n- 弹出 `salt, input_offset, input_size, value`（顺序与 `EXTCALL` 一致，见 [EIP-7069](/eip-7069/)）。\n- 收取 32,000 gas，在静态上下文中失败，检查调用深度和余额。\n- 把子容器 `initcontainer_index` 作为 initcode 运行，内存切片作为其 calldata。\n- 新地址为 `keccak256(0xff || sender32 || salt)[12:]`。与 [CREATE2](/eip-1014/) 不同，initcode 哈希**不**包含在内，因此地址只取决于部署者和 salt。\n- 成功时压入新地址，失败时压入 `0`；每个已部署字节收取 200 gas。\n\n**`RETURNCODE`（`0xee`）**，带 1 字节立即数 `deploy_container_index`：\n\n- 结束 initcode 帧，并指明哪个子容器成为运行时代码。\n- 弹出 `aux_data_offset, aux_data_size`；该内存会被**追加到已部署容器的数据段**。构造函数参数和 immutable 就是这样在无需修改代码的情况下被固化进去的。\n\n验证规则确保容器索引存在，子容器要么作为 initcode 要么作为运行时代码使用而不能两者兼具，并且 initcode 以 `RETURNCODE` 而不是 `RETURN`/`STOP` 结尾。\n\n在 EOF 代码中，`CREATE` 和 `CREATE2` 会被拒绝。在传统代码中，initcode 以 `0xEF00` 开头的 `CREATE`/`CREATE2` 会提前失败，且不消耗 initcode 的 gas。通过交易进行的顶层部署由 [EIP-7873](/eip-7873/) 单独处理。\n\n## 示例代码\n\n`EOFCREATE` 核心逻辑的伪代码：\n\n```python\ndef eofcreate(frame, initcontainer_index):\n    charge_gas(frame, 32000)\n    assert not frame.is_static\n    salt, in_off, in_size, value = frame.stack.pop_n(4)\n    expand_memory(frame, in_off, in_size)\n\n    init = frame.container.subcontainers[initcontainer_index]\n    if frame.depth \u003e= 1024 or frame.balance \u003c value:\n        frame.stack.push(0); return\n\n    result = execute(init, calldata=frame.memory[in_off:in_off + in_size], value=value)\n    frame.sender.nonce += 1\n    new_address = keccak256(b\"\\xff\" + frame.address.rjust(32, b\"\\0\") + salt)[12:]\n\n    if not result.success:\n        frame.stack.push(0); return\n    deployed = result.deploy_container.with_appended_data(result.aux_data)\n    assert len(deployed) \u003c= 24576\n    set_code(new_address, deployed)\n    charge_gas(frame, 200 * len(deployed))\n    frame.stack.push(new_address)\n```\n\n## 需要注意\n\n- 状态为 **Stagnant**。EOF 整体（元 EIP [EIP-7692](/eip-7692/)）尚未在以太坊主网激活，相关的 EOF EIP 也都是 Stagnant。\n- 想要锁定确切子合约代码的工厂，可以自行把其哈希折叠进 `salt`，因为地址公式中没有包含它。\n- 传统字节码中的 `EOFCREATE` 和 `RETURNCODE` 无效并会中止执行，因此对非 EOF 合约没有任何影响。\n- 主要的安全审查负担落在 [EIP-7873](/eip-7873/) 的 initcode 交易上，因为新的未经验证的代码会在那里进入状态。\n"}},"requiredBy":[7692,7873]}
