{"eip":7511,"title":"Minimal Proxy Contract with PUSH0","description":"Optimizes the previous Minimal Proxy Contract with the PUSH0 opcode","authors":["0xAA (@AmazingAng)","vectorized (@Vectorized)","0age (@0age)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-09-04","requires":[7,211,1167,3855],"discussionsTo":"https://ethereum-magicians.org/t/erc-7511-minimal-proxy-contract-with-push0/15662","repo":"ERCs","label":"ERC-7511","officialUrl":"https://eips.ethereum.org/EIPS/eip-7511","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7511.md","url":"https://eips.huatuo.xyz/eip-7511/","tldr":{"en":"A 44-byte version of the ERC-1167 minimal proxy rewritten with the PUSH0 opcode, saving 200 gas at deployment and 5 gas per call while behaving the same.","ja":"ERC-1167 ミニマルプロキシを PUSH0 オペコードで書き直した 44 バイト版。同じ動作のまま、デプロイ時に 200 ガス、呼び出しごとに 5 ガスを節約する。","ko":"ERC-1167 최소 프록시를 PUSH0 옵코드로 다시 쓴 44바이트 버전. 동작은 같으면서 배포 시 200 gas, 호출당 5 gas를 아낀다.","zh":"用 PUSH0 操作码重写的 ERC-1167 最小代理的 44 字节版本，行为不变，部署时节省 200 gas，每次调用节省 5 gas。"},"tags":["proxy","clones","bytecode","gas","push0"],"explainers":{"en":{"lang":"en","tldr":"A 44-byte version of the ERC-1167 minimal proxy rewritten with the PUSH0 opcode, saving 200 gas at deployment and 5 gas per call while behaving the same.","tags":["proxy","clones","bytecode","gas","push0"],"related":[1167,3855,7,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7511/","markdown":"## What problem does it solve?\n\n[ERC-1167](/eip-1167/) \"minimal proxies\" (clones) are tiny contracts that forward every call via `DELEGATECALL` to a fixed implementation. They are the standard way to deploy many cheap copies of the same logic: wallets, vaults, token instances.\n\nERC-1167 was written before the Shanghai upgrade, so it pushes zeros using tricks like `RETURNDATASIZE` and `DUP`. [EIP-3855](/eip-3855/) added `PUSH0`, a dedicated 2-gas opcode for pushing zero. ERC-7511 redesigns the clone from scratch with `PUSH0`, making it one byte smaller, slightly cheaper and easier to read.\n\n## How it works\n\nThe runtime code is exactly 44 bytes, with the 20-byte implementation address at byte indices 9–28 (shown here as `bebe…`):\n\n```\n365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3\n```\n\nIt does four things:\n\n1. `CALLDATACOPY` the full calldata to memory at 0.\n2. `DELEGATECALL` the implementation with all remaining gas.\n3. `RETURNDATACOPY` the result to memory at 0.\n4. `JUMPI` on success: `RETURN` the data, otherwise `REVERT` with it.\n\nThe 53-byte creation code prepends a 9-byte initcode (`602c8060095f395ff3`) that copies the 44-byte runtime code into memory and returns it.\n\nAccording to the spec, compared to ERC-1167 this saves 200 gas at deployment and 5 gas at runtime, with identical behaviour.\n\n## Sample code\n\nA factory from the spec that deploys a clone with `CREATE`:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract Clone0Factory {\n    error FailedCreateClone();\n\n    function clone0(address impl) public payable returns (address addr) {\n        // first 18 bytes of the creation code\n        bytes memory data1 = hex\"602c8060095f395ff3365f5f375f5f365f73\";\n        // last 15 bytes of the creation code\n        bytes memory data2 = hex\"5af43d5f5f3e5f3d91602a57fd5bf3\";\n        bytes memory code = abi.encodePacked(data1, impl, data2);\n\n        assembly {\n            addr := create(callvalue(), add(code, 0x20), mload(code))\n        }\n        if (addr == address(0)) revert FailedCreateClone();\n    }\n}\n```\n\nChecking whether a deployed contract is an ERC-7511 clone (ethers v6):\n\n```ts\nconst code = (await provider.getCode(addr)).toLowerCase();\nconst isClone0 =\n  code.length === 2 + 44 * 2 \u0026\u0026\n  code.startsWith(\"0x365f5f375f5f365f73\") \u0026\u0026\n  code.endsWith(\"5af43d5f5f3e5f3d91602a57fd5bf3\");\nconst impl = isClone0 ? \"0x\" + code.slice(2 + 9 * 2, 2 + 29 * 2) : null;\n```\n\n## Things to know\n\n- Status is **Draft**.\n- Requires `PUSH0`, so it only works on chains that activated Shanghai (or equivalent) and with Solidity targeting an EVM version that supports it. On chains without `PUSH0`, deployment produces a broken contract; use ERC-1167 there.\n- The same caveats as ERC-1167 apply: the implementation is fixed forever (not upgradeable), there is no constructor so you must call an initializer right after deployment, and a bug in the implementation affects every clone.\n- Explorers and tools that only recognise the ERC-1167 bytecode may show these clones as unknown contracts.\n"},"ja":{"lang":"ja","tldr":"ERC-1167 ミニマルプロキシを PUSH0 オペコードで書き直した 44 バイト版。同じ動作のまま、デプロイ時に 200 ガス、呼び出しごとに 5 ガスを節約する。","tags":["proxy","clones","bytecode","gas","push0"],"related":[1167,3855,7,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7511/","markdown":"## 何を解決するのか\n\n[ERC-1167](/eip-1167/) の「ミニマルプロキシ」（クローン）は、すべての呼び出しを `DELEGATECALL` で固定の実装へ転送する小さなコントラクトです。同じロジックの安価なコピーを大量にデプロイする標準的な方法で、ウォレット、ボールト、トークンのインスタンスなどに使われます。\n\nERC-1167 は Shanghai アップグレードより前に書かれたため、ゼロのプッシュに `RETURNDATASIZE` や `DUP` といったトリックを使っています。[EIP-3855](/eip-3855/) は、ゼロをプッシュするための専用の 2 ガスのオペコード `PUSH0` を追加しました。ERC-7511 は `PUSH0` を使ってクローンをゼロから設計し直し、1 バイト小さく、わずかに安く、読みやすくしています。\n\n## 仕組み\n\nランタイムコードはちょうど 44 バイトで、20 バイトの実装アドレスがバイトインデックス 9〜28 にあります（ここでは `bebe…` と表記）。\n\n```\n365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3\n```\n\n次の 4 つのことを行います。\n\n1. calldata 全体を `CALLDATACOPY` でメモリの 0 番地へコピーする。\n2. 残りのガスをすべて渡して実装を `DELEGATECALL` する。\n3. 結果を `RETURNDATACOPY` でメモリの 0 番地へコピーする。\n4. 成功なら `JUMPI` で `RETURN` してデータを返し、そうでなければそのデータとともに `REVERT` する。\n\n53 バイトの作成コードは、44 バイトのランタイムコードをメモリへコピーして返す 9 バイトの initcode（`602c8060095f395ff3`）を先頭に付けたものです。\n\n仕様によると、ERC-1167 と比べてデプロイ時に 200 ガス、実行時に 5 ガスを節約でき、動作は同一です。\n\n## サンプルコード\n\n仕様にある、`CREATE` でクローンをデプロイするファクトリ:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract Clone0Factory {\n    error FailedCreateClone();\n\n    function clone0(address impl) public payable returns (address addr) {\n        // first 18 bytes of the creation code\n        bytes memory data1 = hex\"602c8060095f395ff3365f5f375f5f365f73\";\n        // last 15 bytes of the creation code\n        bytes memory data2 = hex\"5af43d5f5f3e5f3d91602a57fd5bf3\";\n        bytes memory code = abi.encodePacked(data1, impl, data2);\n\n        assembly {\n            addr := create(callvalue(), add(code, 0x20), mload(code))\n        }\n        if (addr == address(0)) revert FailedCreateClone();\n    }\n}\n```\n\nデプロイ済みコントラクトが ERC-7511 のクローンかどうかを確認する（ethers v6）:\n\n```ts\nconst code = (await provider.getCode(addr)).toLowerCase();\nconst isClone0 =\n  code.length === 2 + 44 * 2 \u0026\u0026\n  code.startsWith(\"0x365f5f375f5f365f73\") \u0026\u0026\n  code.endsWith(\"5af43d5f5f3e5f3d91602a57fd5bf3\");\nconst impl = isClone0 ? \"0x\" + code.slice(2 + 9 * 2, 2 + 29 * 2) : null;\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。\n- `PUSH0` が必要なので、Shanghai（または同等のもの）を有効にしたチェーンでのみ動作し、それをサポートする EVM バージョンを対象とする Solidity が必要です。`PUSH0` のないチェーンでは、デプロイすると壊れたコントラクトができるので、そこでは ERC-1167 を使ってください。\n- ERC-1167 と同じ注意点が当てはまります。実装は永久に固定され（アップグレード不可）、コンストラクタがないためデプロイ直後に初期化関数を呼ぶ必要があり、実装のバグはすべてのクローンに影響します。\n- ERC-1167 のバイトコードだけを認識するエクスプローラーやツールは、これらのクローンを未知のコントラクトとして表示することがあります。\n"},"ko":{"lang":"ko","tldr":"ERC-1167 최소 프록시를 PUSH0 옵코드로 다시 쓴 44바이트 버전. 동작은 같으면서 배포 시 200 gas, 호출당 5 gas를 아낀다.","tags":["proxy","clones","bytecode","gas","push0"],"related":[1167,3855,7,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7511/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-1167](/eip-1167/)의 \"최소 프록시\"(클론)는 모든 호출을 `DELEGATECALL`로 고정된 구현체에 전달하는 아주 작은 컨트랙트입니다. 같은 로직의 저렴한 사본을 많이 배포하는 표준적인 방법으로, 지갑, 볼트, 토큰 인스턴스 등에 쓰입니다.\n\nERC-1167은 상하이 업그레이드 이전에 작성되었기 때문에 0을 푸시하는 데 `RETURNDATASIZE`와 `DUP` 같은 요령을 씁니다. [EIP-3855](/eip-3855/)는 0을 푸시하기 위한 전용 2 gas 옵코드 `PUSH0`을 추가했습니다. ERC-7511은 `PUSH0`으로 클론을 처음부터 다시 설계해, 1바이트 더 작고 약간 더 저렴하며 읽기도 쉽게 만들었습니다.\n\n## 어떻게 동작하나요?\n\n런타임 코드는 정확히 44바이트이며, 20바이트 구현체 주소는 바이트 인덱스 9–28에 있습니다(여기서는 `bebe…`로 표시).\n\n```\n365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3\n```\n\n이 코드는 네 가지 일을 합니다.\n\n1. 전체 calldata를 `CALLDATACOPY`로 메모리 0번 위치에 복사합니다.\n2. 남은 gas를 모두 넘겨 구현체를 `DELEGATECALL`합니다.\n3. 결과를 `RETURNDATACOPY`로 메모리 0번 위치에 복사합니다.\n4. 성공 여부에 따라 `JUMPI`로 분기해, 성공이면 데이터를 `RETURN`하고 아니면 그 데이터와 함께 `REVERT`합니다.\n\n53바이트의 생성 코드는 44바이트 런타임 코드를 메모리로 복사해 반환하는 9바이트 initcode(`602c8060095f395ff3`)를 앞에 붙인 것입니다.\n\n명세에 따르면 ERC-1167과 비교해 배포 시 200 gas, 실행 시 5 gas를 아끼며 동작은 동일합니다.\n\n## 샘플 코드\n\n명세에 있는, `CREATE`로 클론을 배포하는 팩토리:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract Clone0Factory {\n    error FailedCreateClone();\n\n    function clone0(address impl) public payable returns (address addr) {\n        // first 18 bytes of the creation code\n        bytes memory data1 = hex\"602c8060095f395ff3365f5f375f5f365f73\";\n        // last 15 bytes of the creation code\n        bytes memory data2 = hex\"5af43d5f5f3e5f3d91602a57fd5bf3\";\n        bytes memory code = abi.encodePacked(data1, impl, data2);\n\n        assembly {\n            addr := create(callvalue(), add(code, 0x20), mload(code))\n        }\n        if (addr == address(0)) revert FailedCreateClone();\n    }\n}\n```\n\n배포된 컨트랙트가 ERC-7511 클론인지 확인하기(ethers v6):\n\n```ts\nconst code = (await provider.getCode(addr)).toLowerCase();\nconst isClone0 =\n  code.length === 2 + 44 * 2 \u0026\u0026\n  code.startsWith(\"0x365f5f375f5f365f73\") \u0026\u0026\n  code.endsWith(\"5af43d5f5f3e5f3d91602a57fd5bf3\");\nconst impl = isClone0 ? \"0x\" + code.slice(2 + 9 * 2, 2 + 29 * 2) : null;\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다.\n- `PUSH0`이 필요하므로 상하이(또는 그에 상응하는) 업그레이드를 활성화한 체인에서만 동작하며, 이를 지원하는 EVM 버전을 대상으로 하는 Solidity가 필요합니다. `PUSH0`이 없는 체인에서는 배포하면 망가진 컨트랙트가 만들어지므로, 그곳에서는 ERC-1167을 사용하세요.\n- ERC-1167과 같은 주의점이 적용됩니다. 구현체는 영원히 고정되고(업그레이드 불가), 생성자가 없으므로 배포 직후 초기화 함수를 호출해야 하며, 구현체의 버그는 모든 클론에 영향을 줍니다.\n- ERC-1167 바이트코드만 인식하는 익스플로러와 도구는 이 클론을 알 수 없는 컨트랙트로 표시할 수 있습니다.\n"},"zh":{"lang":"zh","tldr":"用 PUSH0 操作码重写的 ERC-1167 最小代理的 44 字节版本，行为不变，部署时节省 200 gas，每次调用节省 5 gas。","tags":["proxy","clones","bytecode","gas","push0"],"related":[1167,3855,7,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7511/","markdown":"## 它解决什么问题？\n\n[ERC-1167](/eip-1167/) 的\"最小代理\"（克隆）是一种很小的合约，它通过 `DELEGATECALL` 把每次调用都转发给固定的实现合约。这是部署大量廉价、逻辑相同的副本的标准方式：钱包、金库、代币实例等。\n\nERC-1167 写于上海升级之前，所以它用 `RETURNDATASIZE` 和 `DUP` 之类的技巧来压入零。[EIP-3855](/eip-3855/) 新增了 `PUSH0`，这是一个专门用于压入零的 2 gas 操作码。ERC-7511 用 `PUSH0` 从头重新设计了克隆合约，让它小了一个字节，稍微便宜一些，也更易读。\n\n## 它如何运作\n\n运行时代码正好 44 字节，20 字节的实现地址位于字节索引 9–28（此处显示为 `bebe…`）：\n\n```\n365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3\n```\n\n它做四件事：\n\n1. 用 `CALLDATACOPY` 把完整的 calldata 复制到内存的 0 位置。\n2. 带着所有剩余 gas 对实现合约执行 `DELEGATECALL`。\n3. 用 `RETURNDATACOPY` 把结果复制到内存的 0 位置。\n4. 通过 `JUMPI` 判断成功与否：成功则 `RETURN` 该数据，否则带着该数据 `REVERT`。\n\n53 字节的创建代码，是在前面加上一段 9 字节的 initcode（`602c8060095f395ff3`），它把 44 字节的运行时代码复制到内存并返回。\n\n根据规范，与 ERC-1167 相比，部署时节省 200 gas，运行时节省 5 gas，行为完全相同。\n\n## 示例代码\n\n规范中用 `CREATE` 部署克隆的工厂合约：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ncontract Clone0Factory {\n    error FailedCreateClone();\n\n    function clone0(address impl) public payable returns (address addr) {\n        // first 18 bytes of the creation code\n        bytes memory data1 = hex\"602c8060095f395ff3365f5f375f5f365f73\";\n        // last 15 bytes of the creation code\n        bytes memory data2 = hex\"5af43d5f5f3e5f3d91602a57fd5bf3\";\n        bytes memory code = abi.encodePacked(data1, impl, data2);\n\n        assembly {\n            addr := create(callvalue(), add(code, 0x20), mload(code))\n        }\n        if (addr == address(0)) revert FailedCreateClone();\n    }\n}\n```\n\n检查已部署的合约是否为 ERC-7511 克隆（ethers v6）：\n\n```ts\nconst code = (await provider.getCode(addr)).toLowerCase();\nconst isClone0 =\n  code.length === 2 + 44 * 2 \u0026\u0026\n  code.startsWith(\"0x365f5f375f5f365f73\") \u0026\u0026\n  code.endsWith(\"5af43d5f5f3e5f3d91602a57fd5bf3\");\nconst impl = isClone0 ? \"0x\" + code.slice(2 + 9 * 2, 2 + 29 * 2) : null;\n```\n\n## 需要注意\n\n- 状态为 **Draft**。\n- 需要 `PUSH0`，因此只适用于已激活上海（或等效）升级的链，并且 Solidity 要面向支持它的 EVM 版本。在没有 `PUSH0` 的链上，部署会产生一个损坏的合约；那里请使用 ERC-1167。\n- ERC-1167 的注意事项同样适用：实现永远固定（不可升级），没有构造函数，因此部署后必须立刻调用初始化函数，实现中的漏洞会影响每一个克隆。\n- 只认识 ERC-1167 字节码的浏览器和工具，可能会把这些克隆显示为未知合约。\n"}}}
