Blockchain Technology Smart Contract Fundamentals 5 — Questions and Answers
Question 1: What is a 'time lock' contract, and why do DeFi protocols use them?
- A contract that locks tokens based on the current ETH price
- A contract that enforces a mandatory delay between proposing and executing governance changes (Correct answer)
- A contract that pays staking rewards only at fixed calendar dates
- A contract that batches hourly transactions to save gas
Correct answer: A contract that enforces a mandatory delay between proposing and executing governance changes
Time locks impose a waiting period (e.g., 48 hours) on admin actions, giving users time to react and exit before potentially harmful changes take effect.
Question 2: What is the purpose of the 'modifier' keyword in Solidity?
- It marks a function as upgradeable by the contract owner
- It defines reusable pre/post condition checks that wrap function execution (Correct answer)
- It restricts a function to be called only once per block
- It converts a function's return type to a different data format
Correct answer: It defines reusable pre/post condition checks that wrap function execution
Modifiers inject guard logic (like onlyOwner or nonReentrant) around a function, making access control and validation reusable across many functions.
Question 3: In the context of Ethereum smart contracts, what is 'MEV' (Maximal Extractable Value)?
- The maximum ETH that miners can earn from a single coinbase block reward
- Profit extracted by reordering, inserting, or censoring transactions within a block (Correct answer)
- The upper limit of gas a contract can consume in one transaction
- The maximum validator reward for correctly attesting to finalized blocks
Correct answer: Profit extracted by reordering, inserting, or censoring transactions within a block
MEV refers to value that block producers (miners/validators) or searchers can capture by controlling transaction ordering, enabling strategies like arbitrage and liquidations.
Question 4: What does the 'immutable' keyword do in Solidity?
- Prevents the variable from being read outside the contract
- Allows a variable to be set once at construction and then permanently read-only (Correct answer)
- Makes a mapping that cannot be deleted after deployment
- Marks a function that can never be overridden by child contracts
Correct answer: Allows a variable to be set once at construction and then permanently read-only
'immutable' variables are written once in the constructor and then inlined into the bytecode, making reads cheaper than storage reads while still being configurable per deployment.
Question 5: What is a 'Soulbound Token' (SBT) as proposed by Vitalik Buterin?
- A token that burns itself after one use to prevent double-spending
- A non-transferable NFT permanently linked to a specific wallet as a form of digital identity or credential (Correct answer)
- A token that gains value automatically over time through built-in inflation mechanics
- A governance token that grants voting rights proportional to holding duration
Correct answer: A non-transferable NFT permanently linked to a specific wallet as a form of digital identity or credential
SBTs are non-transferable tokens that represent credentials, achievements, or memberships tied to an individual's on-chain identity, similar to a digital resume.
Question 6: What does 'ABI encoding' accomplish when you call a smart contract function externally?
- It encrypts the function call so only the contract owner can read it
- It serializes the function selector and arguments into bytes the EVM can parse (Correct answer)
- It compresses the transaction payload to reduce gas costs automatically
- It translates Solidity source code into EVM opcodes at runtime
Correct answer: It serializes the function selector and arguments into bytes the EVM can parse
ABI encoding converts a function name and its typed arguments into a standardized byte array: the first 4 bytes are the function selector, followed by encoded parameters.
Question 7: Which design pattern is commonly used to deploy many identical smart contracts efficiently?
- Singleton pattern
- Factory pattern (Correct answer)
- Strategy pattern
- Iterator pattern
Correct answer: Factory pattern
A factory contract deploys new instances of a target contract on demand, often storing references to deployed clones and reducing code duplication.
What is a 'time lock' contract, and why do DeFi protocols use them?