ERC-7511 · Draft · ERC · 2023-09-04
ERC-7511: Minimal Proxy Contract with PUSH0
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.
What problem does it solve?
ERC-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.
ERC-1167 was written before the Shanghai upgrade, so it pushes zeros using tricks like RETURNDATASIZE and DUP. 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.
How it works
The runtime code is exactly 44 bytes, with the 20-byte implementation address at byte indices 9–28 (shown here as bebe…):
365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3
It does four things:
CALLDATACOPYthe full calldata to memory at 0.DELEGATECALLthe implementation with all remaining gas.RETURNDATACOPYthe result to memory at 0.JUMPIon success:RETURNthe data, otherwiseREVERTwith it.
The 53-byte creation code prepends a 9-byte initcode (602c8060095f395ff3) that copies the 44-byte runtime code into memory and returns it.
According to the spec, compared to ERC-1167 this saves 200 gas at deployment and 5 gas at runtime, with identical behaviour.
Sample code
A factory from the spec that deploys a clone with CREATE:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;
contract Clone0Factory {
error FailedCreateClone();
function clone0(address impl) public payable returns (address addr) {
// first 18 bytes of the creation code
bytes memory data1 = hex"602c8060095f395ff3365f5f375f5f365f73";
// last 15 bytes of the creation code
bytes memory data2 = hex"5af43d5f5f3e5f3d91602a57fd5bf3";
bytes memory code = abi.encodePacked(data1, impl, data2);
assembly {
addr := create(callvalue(), add(code, 0x20), mload(code))
}
if (addr == address(0)) revert FailedCreateClone();
}
}
Checking whether a deployed contract is an ERC-7511 clone (ethers v6):
const code = (await provider.getCode(addr)).toLowerCase();
const isClone0 =
code.length === 2 + 44 * 2 &&
code.startsWith("0x365f5f375f5f365f73") &&
code.endsWith("5af43d5f5f3e5f3d91602a57fd5bf3");
const impl = isClone0 ? "0x" + code.slice(2 + 9 * 2, 2 + 29 * 2) : null;
Things to know
- Status is Draft.
- 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 withoutPUSH0, deployment produces a broken contract; use ERC-1167 there. - 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.
- Explorers and tools that only recognise the ERC-1167 bytecode may show these clones as unknown contracts.