Developing Proxy Contracts (UUPS, Transparent Proxy)
Your contract is deployed on mainnet, and a critical vulnerability is found. Without a proxy — tough luck: manual migration, begging users to move to a new address, abandoning the old TVL. We get it: with a properly configured proxy — upgrade via multisig in 15 minutes, contract address unchanged. But "properly configured" is the key phrase. Proxy patterns introduce a whole class of vulnerabilities absent in immutable contracts: storage collision, uninitialized implementations, loss of upgrade rights. Our team has implemented dozens of proxy systems for DeFi protocols with TVL up to $500M over 7 years. Choosing a pattern is not a technical formality but an architectural decision affecting gas, security, and governance. Below, we break down the two main patterns — Transparent Proxy and UUPS — their trade-offs and common mistakes, along with how we design and test such systems.
Problems We Solve
The primary goal is to enable bug fixes and feature additions without user migration. But this comes at a cost:
- Storage collision: variables can be overwritten during an upgrade — silent data corruption.
- Uninitialized implementation: if
initialize()is forgotten, an attacker can take control of the contract. - Loss of upgrade rights: an implementation without
upgradeTopermanently freezes the contract. - Gas overhead: Transparent Proxy adds an SLOAD per call, critical for high-throughput protocols. For example, with 10,000 transactions daily, the extra gas cost is
1,000,000 gas ($20 at current prices, saving 30% with UUPS).
Two Patterns and Their Real Differences
Transparent Proxy
Classic implementation from OpenZeppelin following EIP-1967. The proxy contract contains routing logic: if the caller is the admin — they interact directly (upgrade, changeAdmin). If anyone else — the call is delegated to the implementation.
Problem: every contract call requires an extra SLOAD to read the admin address (100 gas per EIP-2929) and compare with msg.sender. On hot paths — this is a permanent overhead. For a protocol with millions of daily calls — it's significant. Second, ProxyAdmin is a separate contract owning upgrade rights. This adds another contract and another key management point.
Why UUPS Is the Industry Standard Today
Upgrade logic is moved from the proxy to the implementation. The proxy itself becomes a dumb delegator without any caller-based routing. No extra SLOAD per call — cheaper to operate. OpenZeppelin starting from version 4.x recommends UUPS for new projects, as confirmed in the official repository.
But there is a critical risk: if you deploy a new implementation without the upgradeTo function (forgot to inherit UUPSUpgradeable, or intentionally removed it to save gas) — the proxy permanently loses the ability to upgrade. The contract is frozen on the current version with no way to fix it.
Real case: several protocols using UUPS faced uninitialized implementation issues. The implementation was deployed without calling initialize(), and an attacker called initialize() first, becoming the owner, then used upgradeTo() to replace the implementation with a self-destructing contract. All proxies pointing to that implementation became broken. Solution: _disableInitializers() in the implementation constructor — a mandatory pattern in OpenZeppelin 4.3+. We include this in every deployment.
How to Avoid Storage Collision at Design Time
Essence: proxy and implementation share the same storage. If the proxy has a variable in slot 0 and the implementation also has a variable in slot 0 — they overwrite each other.
EIP-1967 solves this for proxy-specific variables (implementation address, admin address) by storing them in pseudo-random slots based on keccak256 hash of a string, virtually eliminating collision with user storage.
But the implementation storage during upgrades is the developer's responsibility. If V1 had the structure:
uint256 public totalSupply; // slot 0
address public owner; // slot 1
And V2 adds a variable before existing ones:
bool public paused; // slot 0 — COLLISION with totalSupply
uint256 public totalSupply; // slot 1 — COLLISION with owner
address public owner; // slot 2
totalSupply now reads what was previously owner (an address interpreted as a number). Silent data corruption, without reverting transactions or compiler errors.
ERC-7201 (Namespaced Storage Layout) solves this radically. All implementation variables are gathered into one struct stored in a precomputed slot:
bytes32 private constant STORAGE_LOCATION =
keccak256(abi.encode(uint256(keccak256("myprotocol.storage.v1")) - 1)) & ~bytes32(uint256(0xff));
New variables are added to the end of the struct. No collisions with proxy-specific slots, no problems during upgrades. This is the current best practice for production UUPS contracts.
How to Initialize a Proxy Contract
In proxy architecture, the implementation constructor is not executed in the proxy context — it only runs during the implementation deployment itself. Therefore all initialization actions (setting owner, initial parameters) are moved to an initialize() function protected by the initializer modifier.
Common bug: initialize() was forgotten after proxy deployment. The contract works, but the owner is not set — the first caller of initialize() becomes the owner. In a WalletLibrary contract incident, 587 ETH (worth ~$1.5M at the time) was lost due to an uninitialized contract takeover. Solution: deploy scripts should atomically deploy the proxy and call initialize() within a single script. Never deploy a proxy without immediate initialization.
What's Included in Our Work (Deliverables)
- Full proxy smart contract code (Solidity) with chosen pattern (UUPS or Transparent).
- Storage layout design using ERC-7201 to prevent collisions.
- Deployment scripts (Hardhat/Foundry) with atomic initialization.
- Unit and fork tests verifying upgrade safety.
- Integration with multisig or DAO governance for upgrade rights.
- Detailed documentation covering upgrade procedures.
- Post-deployment support for 30 days.
How We Implement Proxy Contracts
Base library — OpenZeppelin Upgrades (Hardhat plugin or Foundry-compatible variant). The plugin automatically checks storage layout compatibility between versions on every upgrade — this is mandatory, not optional.
For UUPS, we use UUPSUpgradeable from OpenZeppelin 5.x. For systems where upgrades should be governed by a DAO or multisig — AccessControlUpgradeable with UPGRADER_ROLE granted to the Gnosis Safe address.
We test upgrades via Foundry fork tests: fork mainnet, simulate the upgrade, verify that all storage variables preserve values, functions work correctly, new variables are initialized properly.
| Criterion | Transparent Proxy | UUPS |
|---|---|---|
| Gas per call | +100-200 gas (SLOAD admin) | No overhead |
| Upgrade loss risk | No | Yes (missing upgradeTo) |
| Code complexity | Lower | Slightly higher |
| OZ 5.x recommendation | Deprecated for new | Preferred |
| Separate ProxyAdmin | Yes | No |
When a Proxy Is Not Needed
An immutable contract is simpler, cheaper to audit, and inspires more user trust (no rug risk via upgrade). If the logic is stable and the risk of critical error is minimal — a proxy adds complexity without necessity. For DeFi protocols with large TVL, immutable + timelock on parameters is often better than upgradeability without formal governance. However, if you anticipate the need for updates — a proxy is indispensable.
Process and Timelines
- Requirements analysis — 1-2 days. Pattern selection, role and timelock definition.
- Storage layout design — 1 day. ERC-7201 schema, collision check.
- Implementation development — 2-3 days. Solidity code with Foundry fork tests.
- Deployment and initialization — 1 day. Atomic deploy via script.
- Upgrade testing — 1 day. Storage compatibility verification.
- Internal audit — 2-4 days. Includes Slither, Mythril, and manual review.
Total timeline: from 5 business days for a simple proxy to 2-3 weeks for complex systems with governance and multiple implementations. Contact us for a precise estimate for your project — we'll calculate the timeline end-to-end. Typical cost ranges from $8,000 to $30,000 depending on complexity.
Checklist for Safe Proxy Deployment
- [ ] Pattern chosen (UUPS / Transparent) with justification.
- [ ] Storage layout implemented via ERC-7201.
- [ ]
_disableInitializers()called in implementation constructor. - [ ] Deploy script atomically calls
initialize(). - [ ] ProxyAdmin (if Transparent) deployed and configured.
- [ ]
UPGRADER_ROLEassigned to multisig. - [ ] Storage compatibility checked with OpenZeppelin plugin.
- [ ] Fork tests simulate upgrade with data preservation.
- [ ] Audit conducted (internal or external).
- [ ] Upgrade procedure documentation prepared.
Guarantee and Experience
We have developed over 50 proxy systems for DeFi, NFT, and infrastructure projects. 7+ years of hands-on Solidity and Ethereum experience. Each project is accompanied by an audit, and we provide a guarantee of upgrade correctness on testnet. Get a consultation on pattern and architecture selection for your project — it's free.







