A proxy in Solidity is a design pattern used to enable contract upgradability. This is important because smart contract code is immutable once deployed on the blockchain.
A proxy is a smart contract that stores state variables while delegating all its logic to one or several implementation contracts.
When the proxy receives a call, it forwards it to the logic contract using a low-level delegatecall, which is crucial, because it executes the code from the implementation contract but within the context (storage, msg.sender, msg.value, etc.) of the proxy contract itself.
The basic upgradeable arhitecture:
- Proxy contract — Stores the state and delegates calls to the implementation
- Implementation contract — Contains the actual logic
- Admin — A separate address(or Multisig even better) that can upgrade the implementation contract address stored in the proxy
Common proxy patterns:
- UUPS (Universal Upgradeable Proxy Standard) — The upgrade logic is in the implementation contract
- Transparent Proxy — Uses a more complex pattern to avoid function selector conflicts
- Beacon Proxy — Multiple proxies can point to a single beacon contract that holds the implementation address
Top comments (0)