Blockchain Technology Smart Contracts and dApps 2 — Questions and Answers
Question 1: Which vulnerability allowed the 2016 DAO hack, draining ~$60M worth of ETH?
- Integer overflow
- Reentrancy attack (Correct answer)
- Front-running exploit
- Timestamp manipulation
Correct answer: Reentrancy attack
The DAO hack exploited a reentrancy vulnerability where the attacker's fallback function recursively called withdraw() before the balance was updated.
Question 2: What does the 'payable' keyword do in a Solidity function?
- Allows the function to modify state variables
- Enables the function to receive Ether (Correct answer)
- Marks the function as external only
- Prevents the function from being inherited
Correct answer: Enables the function to receive Ether
The 'payable' modifier allows a Solidity function to receive Ether; without it, any ETH sent to the function will be rejected.
Question 3: In Ethereum, what is the purpose of the ABI (Application Binary Interface)?
- To store contract bytecode on-chain
- To define how to encode and decode function calls and data (Correct answer)
- To manage gas fee calculations
- To establish consensus between nodes
Correct answer: To define how to encode and decode function calls and data
The ABI defines the encoding scheme for function signatures and parameters, allowing external callers to interact with a deployed smart contract.
Question 4: Which dApp architecture pattern uses IPFS or Arweave for storing large data off-chain?
- On-chain maximalist
- Hybrid storage pattern (Correct answer)
- Layer-2 rollup pattern
- Oracle bridge pattern
Correct answer: Hybrid storage pattern
The hybrid storage pattern stores large or mutable data on decentralized file systems (IPFS/Arweave) while anchoring only content hashes on-chain.
Question 5: What is a 'view' function in Solidity?
- A function that emits events but does not change state
- A function that reads state but does not modify it (Correct answer)
- A function restricted to the contract owner
- A function that returns multiple values only
Correct answer: A function that reads state but does not modify it
A 'view' function promises not to modify state, so it can be called without a transaction and without spending gas (when called externally).
Question 6: Which standard defines fungible tokens on Ethereum, used by most DeFi protocols?
- ERC-721
- ERC-1155
- ERC-20 (Correct answer)
- ERC-4626
Correct answer: ERC-20
ERC-20 is the standard interface for fungible tokens on Ethereum, defining transfer, approve, and allowance functions used across DeFi.
Question 7: What problem does the 'checks-effects-interactions' pattern solve in smart contract development?
- Gas optimization for loops
- Reentrancy vulnerabilities (Correct answer)
- Integer overflow errors
- Timestamp dependency attacks
Correct answer: Reentrancy vulnerabilities
The checks-effects-interactions pattern prevents reentrancy by updating all state (effects) before calling external contracts (interactions).
Which vulnerability allowed the 2016 DAO hack, draining ~$60M worth of ETH?