๐๏ธ Proxy Patterns: Transparent vs UUPS
Compare proxy patterns from OpenZeppelin
Learn upgradeable smart contract patterns
Your Progress
0 / 5 completed๐ง Proxy Pattern Comparison
Not all proxy patterns are equal. Transparent Proxy checks if caller is admin on every call (gas cost). UUPS moves upgrade logic to implementation (lower gas, higher risk). Beacon Proxy enables batch upgrades across multiple contracts. Diamond Proxy supports modular logic across multiple contracts (most complex). Each trades off simplicity, gas costs, and flexibility.
๐ฎ Interactive: Proxy Pattern Selector
Select a proxy pattern to see its architecture, upgrade mechanism, trade-offs, gas overhead, and real-world examples. Compare patterns to choose the right approach for your project.
๐ Transparent Proxy
Proxy distinguishes between admin calls and user calls. If msg.sender is admin, execute admin functions (upgrade). Otherwise, delegatecall to Logic.
Admin-only function in Proxy contract. Admin calls upgradeTo(newLogic), Proxy updates implementation address.
- โขSimple to understand and implement
- โขClear separation: admin vs user functions
- โขAdmin can't accidentally call Logic functions
- โขWidely used and battle-tested (OpenZeppelin)
- โขHigher gas costs (if-check on every call)
- โขFunction selector clashing possible
- โขAdmin address stored in Proxy (gas cost)
- โขTransparent to admin, but adds complexity
๐ Pattern Decision Matrix
| Pattern | Complexity | Gas Cost | Use Case |
|---|---|---|---|
| ๐ Transparent | Low | Medium | General purpose |
| โฌ๏ธ UUPS | Medium | Low | High frequency |
| ๐ฆ Beacon | Medium | Medium | Multi-instance |
| ๐ Diamond | High | High | Large protocols |
๐ก Choosing the Right Pattern
If you're new to upgrades, use OpenZeppelin's Transparent Proxy. It's battle-tested, well-documented, and handles most use cases. Gas overhead is acceptable for most applications.
If gas costs matter (high-frequency contract, L2 deployment), switch to UUPS. Lower overhead, but requires careful implementation of upgrade functions in every Logic version.
If deploying many similar contracts (token factory, NFT collections), use Beacon. Upgrade all instances at once, save gas on multiple upgrades.
Only use Diamond if hitting 24KB size limit or need modular upgrades. Most protocols don't need this complexity. Reserve for large, feature-rich systems.
๐ก Key Insight
Proxy patterns are trade-offs, not upgrades. Transparent is simple but costs gas. UUPS saves gas but risks bugs in upgrade logic. Beacon enables batch upgrades but creates single points of failure. Diamond bypasses size limits but introduces complexity. There's no "best" patternโonly the right pattern for your constraints. Most projects should start with Transparent (proven, safe) and only switch to UUPS/Beacon/Diamond when specific needs (gas, batch, size) justify the added complexity.