ERC-7546 · Draft · ERC · 2023-10-25
ERC-7546: Upgradeable Clone for Scalable Contracts
A draft proxy pattern that combines per-function upgrades (like Diamonds) with beacon-style shared upgrades, so many cloned proxies can be upgraded function by function in one transaction.
What problem does it solve?
Existing proxy standards each cover part of the space:
| Need | Existing answer |
|---|---|
| Cheap clones, no upgrades | ERC-1167 minimal proxy |
| Upgrade the whole contract | UUPS / transparent proxies |
| Upgrade many clones at once | Beacon proxy from ERC-1967 |
| Upgrade individual functions | ERC-2535 Diamonds |
What is missing is function-level upgrades for a factory of clones. A Diamond stores its selector-to-facet table inside each proxy, so upgrading 1,000 cloned Diamonds means 1,000 updates. ERC-7546, the Upgradeable Clone Standard (UCS), fills that gap. Splitting logic per function also helps with the 24,576-byte contract size limit.
How it works
One logical contract is split into three parts:
- Proxy: holds the state (balance, storage). It stores the address of a Dictionary in the ERC-1967-style slot
bytes32(uint256(keccak256('erc7546.proxy.dictionary')) - 1). On every call it asks the DictionarygetImplementation(msg.sig)and delegatecalls the result. It should define no external functions of its own, to avoid selector clashes, and emitsDictionaryUpgradedwhen the Dictionary changes. - Dictionary: a shared registry mapping function selectors to implementation addresses, with
getImplementationand usuallysetImplementation, emittingImplementationUpgraded. It may also answer ERC-165supportsInterfacefor the whole set. - Function contracts: the logic, one or more functions each. They run in the proxy's storage via delegatecall.
Because many proxies can point at the same Dictionary, one setImplementation call upgrades a function for all of them at once, like a beacon but per function.
Sample code
A minimal UCS proxy (simplified from the spec's design):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IDictionary {
function getImplementation(bytes4 selector) external view returns (address);
}
contract UCSProxy {
// bytes32(uint256(keccak256("erc7546.proxy.dictionary")) - 1)
bytes32 internal constant DICTIONARY_SLOT =
0x267691be3525af8a813d30db0c9e2bad08f63baecf6dceb85e2cf3676cff56f4;
event DictionaryUpgraded(address dictionary);
constructor(address dictionary, bytes memory initData) {
assembly { sstore(DICTIONARY_SLOT, dictionary) }
emit DictionaryUpgraded(dictionary);
if (initData.length > 0) {
(bool ok, ) = address(this).call(initData);
require(ok, "init failed");
}
}
fallback() external payable {
address dict;
assembly { dict := sload(DICTIONARY_SLOT) }
address impl = IDictionary(dict).getImplementation(msg.sig);
require(impl != address(0), "no impl");
assembly {
calldatacopy(0, 0, calldatasize())
let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch ok case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) }
}
}
}
Things to know
- Status is Draft.
- All function contracts share the proxy's storage, so layout collisions are a real risk. The spec does not fix a method but suggests namespaced storage such as ERC-7201.
- Whoever controls the Dictionary controls every connected proxy's code. Do not attach a proxy to a Dictionary run by an untrusted admin, and consider allowing a switch to another Dictionary.
- Hard-coding the Dictionary address (immutable) can permanently lock you out of changes if the Dictionary admin differs from yours.
- Register a selector only on a function contract that actually implements it; a mismatch makes calls fail. The proxy is not meant to be called with
DELEGATECALL.