What is the proxy pattern in smart contracts?
The proxy pattern splits a contract in two: a proxy that holds the storage, the balance and the address users call, and an implementation that holds the code. The proxy forwards every call with delegatecall, so implementation code runs against proxy storage, and pointing the proxy at a new implementation upgrades the contract.
How does a proxy forward calls?
Its fallback function copies the calldata, delegatecalls the implementation and returns or reverts with whatever came back. ERC-1967 keeps the implementation address at the hash of eip1967.proxy.implementation minus one, a slot the compiler never gives to a variable, so the implementation can't overwrite it by accident (ERC-1967).
A forwarding proxy using the ERC-1967 slot, with no upgrade function (illustrative, not audited code) ForwardingProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
contract ForwardingProxy {
bytes32 internal constant IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(address implementation) {
assembly { sstore(IMPLEMENTATION_SLOT, implementation) }
}
fallback() external payable { _delegate(); }
receive() external payable { _delegate(); }
function _delegate() internal {
assembly {
calldatacopy(0, 0, calldatasize())
let ok := delegatecall(gas(), sload(IMPLEMENTATION_SLOT), 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch ok
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}
Which proxy types are there?
| Type | Upgrade logic | Trade-off |
|---|---|---|
| Transparent | In the proxy, callable only by its admin | Admin calls never reach the implementation |
| UUPS | In the implementation | An implementation without it freezes the proxy |
| Beacon | In a beacon contract many proxies read | One upgrade moves every proxy |
| Minimal clone | None | Cheap copies of fixed code |
What goes wrong with proxies?
- Storage collisions. A new implementation that reorders, removes or retypes variables reads old storage as something else.
- Uninitialized implementations. Constructors don't run in the context of the proxy, so setup moves to an
initializefunction. OpenZeppelin advises locking the implementation with_disableInitializersin its constructor (OpenZeppelin). - Upgrade keys. Whoever can upgrade can replace all the code, so that power belongs behind a multisig and a timelock.
Sources
- ERC-1967: Proxy Storage Slots, Ethereum Requests for Comment checked 3 December 2026
- Proxies API, OpenZeppelin docs checked 3 December 2026