Service
Smart Contract Upgrade Patterns — UUPS, Transparent Proxy, and Diamond Standard Compared
Smart contracts are immutable by default. Three proxy patterns enable upgradeability — with different security trade-offs, gas costs, and governance requirements. Here is when to use each. The immutability argument: Users trust deployed code because it cannot change. An upgradeable contract means the team can change th...
// Implementation contract (contains both logic and upgrade function) import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract LendingPoolV1 is Initializable, UUPSUpgradeable, OwnableUpgradeable { // Storage variab...
solidity // Admin calls go to proxy (admin functions) // User calls delegate to implementation // OpenZeppelin TransparentUpgradeableProxy handles this automatically // Deploy: TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy( address(implementation), address(proxyAdmin), // Only admin can call upgra...
solidity // Multiple implementation contracts (facets) behind one address // Each function selector routes to the appropriate facet // Diamond cut: add/replace/remove facets IDiamond(diamond).diamondCut( cuts, // Array of facet changes address(0), "" ); Pros: No 24KB contract size limit. Separate auditable facets. Fine...
The most critical rule for any upgradeable contract: V1 storage layout: slot 0: totalDeposited (uint256) slot 1: userDeposits (mapping) slots 2-51: __gap[50] V2 MUST NOT change slots 0 and 1. V2 can use slots 2–51 (from the gap). CATASTROPHIC: If V2 changes the type or position of slot 0 or 1, all user balances are cor...
Common integrations: The Graph, Alchemy/Infura, OpenZeppelin Defender, and popular wallet providers.
Clarify requirements, compliance needs, architecture risks, and launch goals.
Implement core contracts, integrations, product flows, tests, and deployment automation.
Run QA, prepare audit handoff, deploy infrastructure, and support production rollout.
No. Simpler, lower-value contracts benefit from immutability — it's a trust signal. Reserve upgradeability for protocols holding significant user value where the governance risk is worth the bug-fix flexibility. At minimum: upgrades should require a TimelockController with 48-hour delay and community governance vote.
Schedule a discovery call and receive a tailored scope and estimate. No commitment required.