CBSA Smart Contracts & Decentralized Applications 5 — Questions and Answers
Question 1: What is the purpose of the OpenZeppelin `Ownable` contract pattern?
- To enable multi-signature governance for contract upgrades
- To provide a standardized access control mechanism restricting certain functions to a designated owner address (Correct answer)
- To automatically distribute contract profits to token holders
- To lock contract funds for a configurable time period
Correct answer: To provide a standardized access control mechanism restricting certain functions to a designated owner address
`Ownable` stores an owner address and provides an `onlyOwner` modifier to restrict sensitive functions to that address.
Question 2: Which smart contract vulnerability occurs when arithmetic operations exceed the maximum or minimum value of a data type?
- Reentrancy
- Integer overflow/underflow (Correct answer)
- Timestamp dependence
- Short address attack
Correct answer: Integer overflow/underflow
Integer overflow/underflow wraps values around their type boundaries (e.g., uint256 max + 1 = 0), which Solidity 0.8+ prevents with built-in checks.
Question 3: In a DAO (Decentralized Autonomous Organization), what mechanism typically governs protocol parameter changes?
- A central admin key held in multi-sig
- On-chain token-weighted voting where governance token holders propose and vote on changes (Correct answer)
- Validator node consensus through proof-of-stake
- Off-chain community polls with manual execution
Correct answer: On-chain token-weighted voting where governance token holders propose and vote on changes
DAOs use governance tokens to give holders voting power proportional to their stake, with proposals executed automatically on-chain if quorum and threshold are met.
Question 4: What distinguishes a 'deterministic' smart contract from one that uses block timestamps or randomness?
- Deterministic contracts are faster to execute due to cached state
- A deterministic contract produces the same output for the same inputs regardless of when or by whom it is executed (Correct answer)
- Deterministic contracts do not require gas to execute
- Deterministic contracts can only run on permissioned blockchains
Correct answer: A deterministic contract produces the same output for the same inputs regardless of when or by whom it is executed
Determinism ensures all nodes reach identical results when replaying the same transaction, which is essential for consensus correctness.
Question 5: What is the Ethereum CREATE2 opcode primarily used for in dApp architectures?
- Deploying contracts with higher gas efficiency than CREATE
- Deploying contracts to a pre-computable deterministic address before the deployment transaction (Correct answer)
- Cloning an existing contract's bytecode with different constructor arguments
- Deploying contracts that can self-destruct and redeploy
Correct answer: Deploying contracts to a pre-computable deterministic address before the deployment transaction
CREATE2 derives the contract address from the deployer, salt, and bytecode, allowing the address to be known and even funded before deployment.
Question 6: Which ERC standard defines a 'vault' interface standardizing how yield-bearing tokens represent shares of underlying assets?
- ERC-777
- ERC-4626 (Correct answer)
- ERC-3525
- ERC-1967
Correct answer: ERC-4626
ERC-4626 standardizes tokenized vault interfaces used by DeFi yield aggregators, making vaults composable across protocols.
Question 7: In smart contract auditing, what does 'formal verification' involve?
- Manually reviewing contract code line-by-line with a checklist
- Using mathematical proofs to verify that a contract's code satisfies a formal specification under all possible inputs (Correct answer)
- Running the contract on a testnet with simulated edge-case transactions
- Checking the ABI against the deployed bytecode for consistency
Correct answer: Using mathematical proofs to verify that a contract's code satisfies a formal specification under all possible inputs
Formal verification applies mathematical methods to prove contract correctness exhaustively, going beyond what testing can achieve.
What is the purpose of the OpenZeppelin `Ownable` contract pattern?