/Solidity Deep Dive
🔐

Solidity Deep Dive

Day 1 · Smart Contracts · 45 min

Transparent Proxy (OpenZeppelin):

  • Proxy contract delegates all calls to implementation
  • Admin can upgrade implementation address
  • ifAdmin modifier prevents admin from accidentally calling implementation functions
  • Storage lives in proxy, logic lives in implementation
UUPS (Universal Upgradeable Proxy Standard):
  • Upgrade logic lives in the implementation, not the proxy
  • Lighter proxy contract (cheaper deployment)
  • Risk: if implementation doesn't include upgrade function, contract becomes non-upgradeable forever
  • Preferred by OpenZeppelin for new projects
Beacon Proxy:
  • Multiple proxies point to a single beacon
  • Beacon stores implementation address
  • Upgrade beacon → all proxies upgrade simultaneously
  • Perfect for factory patterns (many instances of same logic)
Storage Collision:
// BAD: Implementation V1
contract V1 {
uint256 public value; // slot 0
} // BAD: Implementation V2
contract V2 {
address public owner; // slot 0 — COLLISION!
uint256 public value; // slot 1
}

// GOOD: Always append new variables
contract V2 {
uint256 public value; // slot 0 (preserved)
address public owner; // slot 1 (new)
}

Use EIP-1967 storage slots for proxy admin/implementation to avoid collision with implementation storage.

Key Points

  • Transparent Proxy: admin in proxy, ifAdmin modifier
  • UUPS: upgrade logic in implementation, lighter proxy
  • Beacon: one upgrade updates all proxy instances
  • Never reorder storage variables in upgrades
  • Use EIP-1967 storage slots for proxy metadata

Navigate