{"eip":5478,"title":"CREATE2COPY Opcode","description":"Reducing the gas cost of contract creation with existing code","authors":["Qi Zhou (@qizhou)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2022-08-17","requires":[1014,2929],"discussionsTo":"https://ethereum-magicians.org/t/eip-5478-reducing-the-gas-cost-of-contract-creation-with-existing-code/10419","repo":"EIPs","label":"EIP-5478","officialUrl":"https://eips.ethereum.org/EIPS/eip-5478","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-5478.md","url":"https://eips.huatuo.xyz/eip-5478/","tldr":{"en":"Proposed a CREATE2COPY opcode that deploys a contract whose code matches an existing one and charges an account access (2,600 or 100 gas) instead of the per-byte code deposit fee.","ja":"既存のコントラクトとコードが一致するコントラクトをデプロイし、バイトごとのコードデポジット料金の代わりにアカウントアクセス（2,600 または 100 ガス）を課す CREATE2COPY オペコードの提案。","ko":"기존 컨트랙트와 코드가 같은 컨트랙트를 배포하면서, 바이트당 코드 예치 수수료 대신 계정 접근 비용(2,600 또는 100 gas)을 부과하는 CREATE2COPY opcode를 제안한 EIP.","zh":"提议新增 CREATE2COPY 操作码，用于部署与已有合约代码一致的合约，并收取一次账户访问费用（2,600 或 100 gas），而不是按字节计费的代码存款费用。"},"tags":["evm","opcodes","deployment","account-abstraction","gas"],"explainers":{"en":{"lang":"en","tldr":"Proposed a CREATE2COPY opcode that deploys a contract whose code matches an existing one and charges an account access (2,600 or 100 gas) instead of the per-byte code deposit fee.","tags":["evm","opcodes","deployment","account-abstraction","gas"],"related":[1014,2929,1167,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5478/","markdown":"## What problem does it solve?\n\nWith account abstraction, every user gets their own smart-contract wallet, and most of them run *identical* code. Deploying a contract still charges the code deposit cost of 200 gas per byte of runtime code. The spec's example: a 10,000-byte wallet costs 2,000,000 gas in code deposit alone, every time, even though nodes already store that exact code.\n\nEIP-5478 proposes paying only for looking up the existing code instead of re-paying for storing it.\n\n## How it works\n\nA new opcode `CREATE2COPY` (proposed at `0xf6`) behaves like `CREATE2` ([EIP-1014](/eip-1014/)) with one extra stack argument:\n\n```text\nCREATE2COPY(endowment, memory_start, memory_length, salt, existing_contract_address)\n```\n\n- Initcode runs exactly as with `CREATE2`, and the address is derived the same way.\n- The runtime code returned by the initcode MUST have the same code hash as `existing_contract_address`. If it does not, creation fails (\"mismatched contract creation code with existing code\") and all gas for the creation is burned.\n- Gas is the same as `CREATE2`, except the code-deposit term `200 * code_size` is replaced by the cost of an `EXTCODEHASH` on the existing contract: **2,600** if cold, **100** if warm ([EIP-2929](/eip-2929/)).\n\n| Constant | Value |\n| --- | --- |\n| `CREATE_DATA_GAS_PER_BYTE` | 200 |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `WARM_ACCOUNT_ACCESS_COST` | 100 |\n\n## Sample code\n\nHow a wallet factory might use it (hypothetical; no compiler or chain supports this opcode):\n\n```python\n# Pseudocode: CREATE2COPY does not exist on mainnet.\ndef deploy_wallet(factory, initcode: bytes, salt: bytes, template: str) -\u003e str:\n    # Same as CREATE2(endowment=0, initcode, salt) ...\n    # ... but the runtime code must hash-match `template`, and the\n    # 200 gas/byte code deposit is replaced by an EXTCODEHASH-priced access.\n    wallet = factory.CREATE2COPY(0, initcode, salt, template)\n    assert wallet != ZERO_ADDRESS, \"deploy failed\"\n    return wallet\n\n# Gas for a 10,000-byte wallet code deposit:\n#   CREATE2:      200 * 10_000 = 2_000_000\n#   CREATE2COPY:  2_600 (template cold) or 100 (template warm)\n```\n\n## Things to know\n\n- Status: **Stagnant**. The fork block is \"TBD\", and the Rationale and Security Considerations sections were never completed.\n- It only discounts the code deposit. Initcode execution, the base `CREATE2` cost and hashing still apply.\n- Today the usual way to make cheap per-user deployments is a proxy such as [ERC-1167](/eip-1167/), which deploys a few dozen bytes that `DELEGATECALL` into shared logic. That is the pattern [ERC-4337](/eip-4337/) wallet factories commonly use.\n- Unlike a proxy, `CREATE2COPY` would give each account a full, independent copy of the code with no delegatecall overhead.\n"},"ja":{"lang":"ja","tldr":"既存のコントラクトとコードが一致するコントラクトをデプロイし、バイトごとのコードデポジット料金の代わりにアカウントアクセス（2,600 または 100 ガス）を課す CREATE2COPY オペコードの提案。","tags":["evm","opcodes","deployment","account-abstraction","gas"],"related":[1014,2929,1167,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5478/","markdown":"## 何を解決するのか\n\nアカウントアブストラクションでは、すべてのユーザーが自分のスマートコントラクトウォレットを持ち、そのほとんどが*同一の*コードで動きます。コントラクトのデプロイでは、ランタイムコード 1 バイトあたり 200 ガスのコードデポジットコストが今もかかります。仕様の例では、10,000 バイトのウォレットは、ノードがすでにまったく同じコードを保存しているにもかかわらず、コードデポジットだけで毎回 2,000,000 ガスかかります。\n\nEIP-5478 は、保存し直すために再び支払うのではなく、既存のコードを参照する分だけを支払うことを提案します。\n\n## 仕組み\n\n新しいオペコード `CREATE2COPY`（`0xf6` が提案されています）は、スタック引数を 1 つ追加した `CREATE2`（[EIP-1014](/eip-1014/)）のように動作します。\n\n```text\nCREATE2COPY(endowment, memory_start, memory_length, salt, existing_contract_address)\n```\n\n- initcode は `CREATE2` とまったく同じように実行され、アドレスも同じ方法で導出されます。\n- initcode が返すランタイムコードは、`existing_contract_address` と同じコードハッシュでなければなりません（MUST）。そうでない場合、作成は失敗し（「mismatched contract creation code with existing code」）、作成に使われたガスはすべて消費されます。\n- ガスは `CREATE2` と同じですが、コードデポジット項 `200 * code_size` が、既存コントラクトに対する `EXTCODEHASH` のコストに置き換わります。コールドなら **2,600**、ウォームなら **100** です（[EIP-2929](/eip-2929/)）。\n\n| 定数 | 値 |\n| --- | --- |\n| `CREATE_DATA_GAS_PER_BYTE` | 200 |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `WARM_ACCOUNT_ACCESS_COST` | 100 |\n\n## サンプルコード\n\nウォレットファクトリがこれをどう使うかの例（仮想的なもので、このオペコードに対応するコンパイラやチェーンはありません）:\n\n```python\n# Pseudocode: CREATE2COPY does not exist on mainnet.\ndef deploy_wallet(factory, initcode: bytes, salt: bytes, template: str) -\u003e str:\n    # Same as CREATE2(endowment=0, initcode, salt) ...\n    # ... but the runtime code must hash-match `template`, and the\n    # 200 gas/byte code deposit is replaced by an EXTCODEHASH-priced access.\n    wallet = factory.CREATE2COPY(0, initcode, salt, template)\n    assert wallet != ZERO_ADDRESS, \"deploy failed\"\n    return wallet\n\n# Gas for a 10,000-byte wallet code deposit:\n#   CREATE2:      200 * 10_000 = 2_000_000\n#   CREATE2COPY:  2_600 (template cold) or 100 (template warm)\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。フォークブロックは「TBD」で、Rationale と Security Considerations のセクションは完成しませんでした。\n- 割引されるのはコードデポジットだけです。initcode の実行、`CREATE2` の基本コスト、ハッシュ計算は引き続きかかります。\n- 現在、ユーザーごとの安価なデプロイを実現する通常の方法は、[ERC-1167](/eip-1167/) のようなプロキシです。共有ロジックへ `DELEGATECALL` する数十バイトをデプロイします。これは [ERC-4337](/eip-4337/) のウォレットファクトリがよく使うパターンです。\n- プロキシと異なり、`CREATE2COPY` は各アカウントに、delegatecall のオーバーヘッドなしで、コードの完全で独立したコピーを与えることになります。\n"},"ko":{"lang":"ko","tldr":"기존 컨트랙트와 코드가 같은 컨트랙트를 배포하면서, 바이트당 코드 예치 수수료 대신 계정 접근 비용(2,600 또는 100 gas)을 부과하는 CREATE2COPY opcode를 제안한 EIP.","tags":["evm","opcodes","deployment","account-abstraction","gas"],"related":[1014,2929,1167,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5478/","markdown":"## 어떤 문제를 해결하나요?\n\n계정 추상화에서는 모든 사용자가 자신의 스마트 컨트랙트 지갑을 갖게 되고, 대부분은 *동일한* 코드를 실행합니다. 컨트랙트를 배포하면 런타임 코드 바이트당 200 gas의 코드 예치 비용이 여전히 부과됩니다. 스펙의 예시로, 10,000바이트짜리 지갑은 노드가 이미 똑같은 코드를 저장하고 있는데도 코드 예치만으로 매번 2,000,000 gas가 듭니다.\n\nEIP-5478은 코드를 다시 저장하는 비용을 또 내는 대신, 기존 코드를 조회하는 비용만 내자고 제안합니다.\n\n## 어떻게 동작하나요?\n\n새 opcode `CREATE2COPY`(`0xf6` 제안)는 스택 인자가 하나 더 붙은 `CREATE2`([EIP-1014](/eip-1014/))처럼 동작합니다.\n\n```text\nCREATE2COPY(endowment, memory_start, memory_length, salt, existing_contract_address)\n```\n\n- initcode는 `CREATE2`와 똑같이 실행되고, 주소도 같은 방식으로 도출됩니다.\n- initcode가 반환하는 런타임 코드는 `existing_contract_address`와 코드 해시가 같아야 합니다(MUST). 그렇지 않으면 생성이 실패하고(\"mismatched contract creation code with existing code\") 생성에 쓰인 가스는 모두 소각됩니다.\n- 가스는 `CREATE2`와 같지만, 코드 예치 항 `200 * code_size`가 기존 컨트랙트에 대한 `EXTCODEHASH` 비용으로 대체됩니다. 콜드면 **2,600**, 웜이면 **100**입니다([EIP-2929](/eip-2929/)).\n\n| 상수 | 값 |\n| --- | --- |\n| `CREATE_DATA_GAS_PER_BYTE` | 200 |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `WARM_ACCOUNT_ACCESS_COST` | 100 |\n\n## 샘플 코드\n\n지갑 팩토리가 이를 사용하는 방식(가상의 예이며, 이 opcode를 지원하는 컴파일러나 체인은 없습니다):\n\n```python\n# Pseudocode: CREATE2COPY does not exist on mainnet.\ndef deploy_wallet(factory, initcode: bytes, salt: bytes, template: str) -\u003e str:\n    # Same as CREATE2(endowment=0, initcode, salt) ...\n    # ... but the runtime code must hash-match `template`, and the\n    # 200 gas/byte code deposit is replaced by an EXTCODEHASH-priced access.\n    wallet = factory.CREATE2COPY(0, initcode, salt, template)\n    assert wallet != ZERO_ADDRESS, \"deploy failed\"\n    return wallet\n\n# Gas for a 10,000-byte wallet code deposit:\n#   CREATE2:      200 * 10_000 = 2_000_000\n#   CREATE2COPY:  2_600 (template cold) or 100 (template warm)\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 포크 블록은 \"TBD\"이며, Rationale과 Security Considerations 섹션은 끝내 완성되지 않았습니다.\n- 할인되는 것은 코드 예치뿐입니다. initcode 실행, `CREATE2`의 기본 비용, 해싱은 그대로 부과됩니다.\n- 오늘날 사용자별로 저렴하게 배포하는 일반적인 방법은 [ERC-1167](/eip-1167/) 같은 프록시로, 공유 로직으로 `DELEGATECALL`하는 수십 바이트만 배포합니다. [ERC-4337](/eip-4337/) 지갑 팩토리가 흔히 쓰는 패턴입니다.\n- 프록시와 달리 `CREATE2COPY`는 각 계정에 delegatecall 오버헤드 없이 코드의 완전하고 독립적인 사본을 제공합니다.\n"},"zh":{"lang":"zh","tldr":"提议新增 CREATE2COPY 操作码，用于部署与已有合约代码一致的合约，并收取一次账户访问费用（2,600 或 100 gas），而不是按字节计费的代码存款费用。","tags":["evm","opcodes","deployment","account-abstraction","gas"],"related":[1014,2929,1167,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5478/","markdown":"## 它解决什么问题？\n\n在账户抽象下，每个用户都有自己的智能合约钱包，其中大多数运行的是*完全相同*的代码。部署合约时仍然要按运行时代码每字节 200 gas 收取代码存款成本。规范中的例子：一个 10,000 字节的钱包，仅代码存款就要花费 2,000,000 gas，而且每次都是如此，尽管节点早已存储了这份一模一样的代码。\n\nEIP-5478 提议只为查找已有代码付费，而不是为重新存储再付一次费。\n\n## 它如何运作\n\n新操作码 `CREATE2COPY`（提议使用 `0xf6`）的行为类似 `CREATE2`（[EIP-1014](/eip-1014/)），只是多了一个栈参数：\n\n```text\nCREATE2COPY(endowment, memory_start, memory_length, salt, existing_contract_address)\n```\n\n- initcode 的运行方式与 `CREATE2` 完全相同，地址的推导方式也相同。\n- initcode 返回的运行时代码必须（MUST）与 `existing_contract_address` 具有相同的代码哈希。否则创建失败（\"mismatched contract creation code with existing code\"），并烧掉创建所用的全部 gas。\n- gas 与 `CREATE2` 相同，只是代码存款项 `200 * code_size` 被替换为对已有合约执行 `EXTCODEHASH` 的成本：冷访问为 **2,600**，热访问为 **100**（[EIP-2929](/eip-2929/)）。\n\n| 常量 | 值 |\n| --- | --- |\n| `CREATE_DATA_GAS_PER_BYTE` | 200 |\n| `COLD_ACCOUNT_ACCESS_COST` | 2600 |\n| `WARM_ACCOUNT_ACCESS_COST` | 100 |\n\n## 示例代码\n\n钱包工厂可能如何使用它（假设性的；没有编译器或链支持该操作码）：\n\n```python\n# Pseudocode: CREATE2COPY does not exist on mainnet.\ndef deploy_wallet(factory, initcode: bytes, salt: bytes, template: str) -\u003e str:\n    # Same as CREATE2(endowment=0, initcode, salt) ...\n    # ... but the runtime code must hash-match `template`, and the\n    # 200 gas/byte code deposit is replaced by an EXTCODEHASH-priced access.\n    wallet = factory.CREATE2COPY(0, initcode, salt, template)\n    assert wallet != ZERO_ADDRESS, \"deploy failed\"\n    return wallet\n\n# Gas for a 10,000-byte wallet code deposit:\n#   CREATE2:      200 * 10_000 = 2_000_000\n#   CREATE2COPY:  2_600 (template cold) or 100 (template warm)\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。分叉区块为\"TBD\"，Rationale 和 Security Considerations 两节从未完成。\n- 它只对代码存款打折。initcode 的执行、`CREATE2` 的基础成本以及哈希计算仍然照常收费。\n- 如今实现廉价的按用户部署的常用方式是 [ERC-1167](/eip-1167/) 之类的代理，它部署几十字节的代码，再 `DELEGATECALL` 到共享逻辑。这也是 [ERC-4337](/eip-4337/) 钱包工厂常用的模式。\n- 与代理不同，`CREATE2COPY` 会给每个账户一份完整、独立的代码副本，没有 delegatecall 的开销。\n"}}}
