Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the Proxy pattern in upgradeable contracts?
The Proxy pattern is a design that separates contract logic from data storage. It uses a proxy contract to forward calls to a logic contract, allowing the logic to be upgraded without changing the contract address.
Click to reveal answer
beginner
Why do upgradeable contracts use a proxy?
Because blockchain contracts are immutable, a proxy allows changing the logic by pointing to a new implementation contract, while keeping the same address and stored data.
Click to reveal answer
beginner
What is the role of the implementation contract in the Proxy pattern?
The implementation contract contains the actual business logic and functions. The proxy delegates calls to it while storing the data itself.
Click to reveal answer
intermediate
How does the proxy forward calls to the implementation contract?
The proxy uses a special low-level function called 'delegatecall' to execute the implementation's code in the proxy's context, preserving storage and address.
Click to reveal answer
intermediate
What is a common risk when using the Proxy pattern in upgradeable contracts?
Incorrect storage layout between proxy and implementation can cause data corruption. Also, malicious upgrades can change logic unexpectedly.
Click to reveal answer
What does the proxy contract store in upgradeable contracts?
AOnly the contract data
BNeither logic nor data
CBoth logic and data
DOnly the contract logic
✗ Incorrect
The proxy contract stores the data (state variables), while the logic is in the implementation contract.
Which function is used by the proxy to execute the implementation's code?
Atransfer
Bsend
Ccall
Ddelegatecall
✗ Incorrect
The proxy uses 'delegatecall' to run the implementation's code in its own context.
Why is the Proxy pattern important for upgradeable contracts?
AIt prevents any changes to the contract
BIt allows changing the contract address
CIt allows changing the contract logic without changing the address
DIt stores all contract data off-chain
✗ Incorrect
The Proxy pattern lets you upgrade logic while keeping the same contract address and data.
What can happen if storage layouts differ between proxy and implementation?
AData corruption or unexpected behavior
BThe contract will run faster
CThe proxy will ignore the implementation
DThe implementation will be deleted
✗ Incorrect
Different storage layouts can cause data to be read or written incorrectly, leading to errors.
Which of these is NOT a component of the Proxy pattern?
AProxy contract
BStorage contract
CImplementation contract
DDelegatecall mechanism
✗ Incorrect
There is no separate 'Storage contract'; storage is held in the proxy contract.
Explain how the Proxy pattern enables contract upgrades on blockchain.
Think about separating data and logic and how calls are forwarded.
You got /4 concepts.
Describe the risks involved in using the Proxy pattern for upgradeable contracts.
Consider what can go wrong if data or logic changes unexpectedly.
You got /4 concepts.
Practice
(1/5)
1.
What is the main purpose of using the Proxy pattern in smart contracts?
easy
A. To upgrade contract logic without changing the contract address
B. To reduce gas fees by optimizing code
C. To create multiple copies of the same contract
D. To prevent any changes to the contract after deployment
Solution
Step 1: Understand the Proxy pattern role
The Proxy pattern allows a contract to forward calls to another contract, enabling upgrades.
Step 2: Identify the main benefit
This forwarding lets you change the logic contract without changing the proxy's address.
Final Answer:
To upgrade contract logic without changing the contract address -> Option A
Quick Check:
Proxy pattern = Upgrade logic without address change [OK]
Hint: Proxy pattern upgrades logic, keeps address same [OK]
Common Mistakes:
Thinking proxy reduces gas fees
Believing proxy creates contract copies
Assuming proxy prevents all changes
2.
Which Solidity keyword is used inside a proxy contract to forward calls to the implementation contract?
easy
A. delegatecall
B. call
C. transfer
D. send
Solution
Step 1: Recall Solidity call types
Solidity has several low-level calls: call, delegatecall, send, transfer.
Step 2: Identify forwarding call for proxy
Proxy contracts use delegatecall to run implementation code in proxy's context.
Final Answer:
delegatecall -> Option A
Quick Check:
Proxy forwarding uses delegatecall [OK]
Hint: Proxy uses delegatecall to keep storage context [OK]
Common Mistakes:
Confusing call with delegatecall
Using transfer or send which are for Ether
Not knowing delegatecall preserves storage
3.
Consider this simplified proxy contract snippet in Solidity: