EIPs Explained

ERC-7760 · Draft · ERC · 2024-08-19

ERC-7760: Minimal Upgradeable Proxies

Standard hand-written bytecode for minimal ERC-1967 upgradeable proxies (transparent, UUPS and beacon), with optional immutable arguments and 'I-variants' that report their implementation onchain, so cheap upgradeable clones can be auto-verified and inspected.

What problem does it solve?

ERC-1167 minimal proxies made it cheap to deploy many clones of one contract, but those clones cannot be upgraded. Upgradeable proxies, on the other hand, are usually full Solidity contracts: bigger to deploy, a bit more expensive per call, and each project's bytecode is slightly different, so explorers cannot verify them automatically.

ERC-7760 fixes one set of tiny, hand-optimized bytecodes for the three common ERC-1967 upgrade patterns. Because every deployment uses the same bytes, explorers can recognise and verify them automatically, other contracts can read immutable arguments at a known offset, and (with I-variants) the implementation address can be checked onchain.

How it works

Three proxy kinds, each with a basic variant and an I-variant:

  • Transparent: the factory's address is baked into the bytecode, which saves an SLOAD per call. Only the factory can upgrade, by calling the proxy with abi.encodePacked(uint256(uint160(newImpl)), IMPLEMENTATION_SLOT, optionalCalldata). The proxy writes that word into that slot and, if more calldata follows, delegatecalls it. There are 20-byte and shorter 14-byte factory-address subvariants; the latter suits a vanity factory address with six leading zero bytes.
  • UUPS: no upgrade logic in the proxy; the implementation contract handles upgrades. The init code must write the implementation slot 0x3608…2bbc.
  • Beacon: asks the beacon stored in the ERC-1967 beacon slot for implementation() and delegatecalls the result.

Common rules:

  • Immutable arguments may be appended after the runtime bytecode. They are not added to forwarded calldata; read them with EXTCODECOPY.
  • I-variants: a call with exactly 1 byte of calldata returns the implementation address instead of forwarding. Plain ETH transfers send 0 bytes and Solidity calls send at least 4, so there is no clash. Before trusting the answer, a caller must check that the proxy's bytecode (with the factory address zeroed) hashes to the expected value.
  • The proxies avoid PUSH0 (EIP-3855) so they run on chains without it, and they do not emit ERC-1967 events; indexers should read the slots.

Sample code

Querying a proxy's implementation (ethers v6):

import { JsonRpcProvider, getAddress, dataSlice } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const IMPL_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";

// Any ERC-1967 proxy: read the storage slot
const raw = await provider.getStorage(proxy, IMPL_SLOT);
console.log("impl:", getAddress(dataSlice(raw, 12)));

// ERC-7760 I-variant: 1-byte calldata returns the implementation
const ret = await provider.call({ to: proxy, data: "0x00" });
console.log("impl (I-variant):", getAddress(dataSlice(ret, 12)));
// Onchain, also verify the proxy's code hash before trusting this value.

Things to know

  • Status is Draft.
  • Factories, beacons and the onchain verification logic for I-variants are out of scope; they need careful, audited implementations of their own.
  • The transparent proxy lets the factory write any storage slot, so the factory's own access control is the real security boundary.
  • If you only need non-upgradeable clones, ERC-1167 or ERC-3448 (clones with metadata) are simpler.

#proxy #upgradeable #bytecode #erc1967 #clones

Details

Authors
Atarpara (@Atarpara), JT Riley (@jtriley-eth), Thomas (@0xth0mas), xiaobaiskill (@xiaobaiskill), Vectorized (@Vectorized)
Status
Draft
Type
Standards Track / ERC
Created
2024-08-19
Requires

Machine-readable: Markdown · JSON