Blockchain Technology Smart Contract Fundamentals 3 — Questions and Answers
Question 1: What is 'contract upgradeability' and which pattern is most commonly used to achieve it?
- Redeploying a new contract and migrating all state; direct redeployment
- Delegating calls to a swappable logic contract via a persistent proxy; the proxy pattern (Correct answer)
- Storing code on IPFS and updating the hash; content-addressed storage
- Using Ethereum's built-in upgrade opcode; UPGRADECONTRACT
Correct answer: Delegating calls to a swappable logic contract via a persistent proxy; the proxy pattern
The proxy pattern keeps a stable address and storage while delegating logic calls to an implementation contract that can be swapped, enabling upgrades without migrating state.
Question 2: Which type of oracle attack manipulates price feeds to exploit DeFi smart contracts?
- Sybil attack
- Flash loan price manipulation (Correct answer)
- Selfish mining
- Eclipse attack
Correct answer: Flash loan price manipulation
Attackers use flash loans to temporarily skew on-chain price feeds, tricking smart contracts into executing trades at artificially inflated or deflated prices within a single block.
Question 3: What is 'slippage' in the context of automated market maker (AMM) smart contracts?
- The gas fee increase during network congestion
- The difference between expected and executed trade price due to pool ratio changes (Correct answer)
- A rounding error in fixed-point arithmetic within Solidity
- The delay between submitting and confirming a transaction
Correct answer: The difference between expected and executed trade price due to pool ratio changes
Slippage occurs because a trade moves the AMM's token ratio, causing the final execution price to differ from the quoted price at submission.
Question 4: In Solidity, what is the difference between 'memory' and 'storage' data locations?
- memory is persistent across transactions; storage is temporary
- storage is persistent on-chain; memory is temporary and cleared after each call (Correct answer)
- memory holds contract ETH balance; storage holds token balances
- storage is only readable; memory is only writable
Correct answer: storage is persistent on-chain; memory is temporary and cleared after each call
storage variables persist permanently on the blockchain while memory variables exist only for the duration of a function call and are discarded afterward.
Question 5: What is a 'multisig wallet' smart contract, and what problem does it solve?
- A wallet that batches transactions to save gas by combining many senders
- A contract requiring M-of-N key holders to approve a transaction before execution (Correct answer)
- A wallet that automatically signs transactions using zero-knowledge proofs
- A contract that splits ETH equally among multiple recipients atomically
Correct answer: A contract requiring M-of-N key holders to approve a transaction before execution
A multisig wallet requires a threshold number of predefined signatories to co-sign transactions, eliminating single-point-of-failure risk for high-value funds.
Question 6: What is the role of 'events' in Solidity smart contracts?
- They trigger external smart contract calls automatically
- They emit indexed logs stored on-chain that off-chain apps can efficiently query (Correct answer)
- They schedule future function executions at specific block heights
- They replace return values for all external function calls
Correct answer: They emit indexed logs stored on-chain that off-chain apps can efficiently query
Solidity events write log entries to the blockchain that are cheaper than storage and can be efficiently filtered by off-chain services like The Graph or ethers.js.
Question 7: Which vulnerability occurs when a Solidity integer wraps around its maximum or minimum value?
- Reentrancy
- Front-running
- Integer overflow/underflow (Correct answer)
- Delegatecall injection
Correct answer: Integer overflow/underflow
Before Solidity 0.8.0, arithmetic could silently wrap around (e.g., uint8(255) + 1 == 0), allowing attackers to bypass balance checks.
What is 'contract upgradeability' and which pattern is most commonly used to achieve it?