ERC-3561 · Stagnant · ERC · 2021-05-09
ERC-3561: Trust Minimized Upgradeability Proxy
An EIP-1967 proxy extension that forces every upgrade to be announced on-chain and wait out a delay before it takes effect, so users can exit before a malicious upgrade.
What problem does it solve?
An upgradeable proxy lets its admin swap the contract logic at any time. If the admin is anonymous, or their key is compromised, a malicious upgrade can drain users in a single transaction with no warning. That makes upgradeable contracts from anonymous developers hard to trust.
ERC-3561 adds a built-in waiting period to the standard EIP-1967 transparent proxy. A new implementation must first be proposed, which emits an event; it can only be activated after a "Zero Trust Period" of blocks has passed. Users who dislike the new code have time to see it and leave.
How it works
Four extra storage slots, each derived as keccak256(label) - 1 like EIP-1967:
| Slot label | Holds |
|---|---|
eip3561.proxy.next.logic |
Proposed next implementation |
eip3561.proxy.next.logic.block |
Earliest block when upgrade() may run |
eip3561.proxy.propose.block |
Earliest block when a new proposal is allowed |
eip3561.proxy.zero.trust.period |
Delay length in blocks |
Admin flow:
proposeTo(impl, data)storesimplas next logic and emitsNextLogicDefined(impl, earliestArrivalBlock). If no implementation is set yet, or the period is still 0, it upgrades immediately.- After
earliestArrivalBlock,upgrade(data)moves next logic into the EIP-1967 implementation slot and runsdataviadelegatecall. cancelUpgrade()aborts a pending proposal.setZeroTrustPeriod(blocks)can only increase the delay. While it is 0, the proxy behaves like a normal EIP-1967 transparent proxy.prolongLock(block)forbids new proposals until a later block; setting it to the maximum value effectively freezes the code.
All admin actions must emit events and be restricted to the admin.
Sample code
Checking a proxy's delay and watching for proposals (ethers v6):
import { JsonRpcProvider, Contract, keccak256, toUtf8Bytes, toBigInt, toBeHex, zeroPadValue } from "ethers";
const slot = (label: string) => zeroPadValue(toBeHex(toBigInt(keccak256(toUtf8Bytes(label))) - 1n), 32);
const provider = new JsonRpcProvider(process.env.RPC_URL);
const ztp = await provider.getStorage(proxy, slot("eip3561.proxy.zero.trust.period"));
console.log("zero trust period (blocks):", toBigInt(ztp));
const p = new Contract(proxy, [
"event NextLogicDefined(address indexed nextLogic, uint earliestArrivalBlock)",
], provider);
p.on("NextLogicDefined", (next, block) => console.log(`upgrade to ${next} possible at block ${block}`));
Things to know
- Status: Stagnant. Widely used libraries do not implement this proxy; the common pattern is an EIP-1967 or UUPS proxy whose admin is a separate timelock contract.
- The delay only helps if users actually watch for
NextLogicDefinedand can exit in time. The spec suggests a period of at least two weeks, and in most cases at least a month. - The spec advises users to verify that a deployed proxy matches the reference implementation exactly; any deviation can undermine the guarantees.
- The delay is in blocks, so its wall-clock length depends on the chain's block time.