Recall & Review
beginner
What is the Checks-Effects-Interactions pattern in smart contract programming?
It is a design pattern that helps prevent security issues by first checking conditions, then updating the contract's state, and finally interacting with other contracts or external addresses.
Click to reveal answer
beginner
Why do we perform checks before effects and interactions in the Checks-Effects-Interactions pattern?
Performing checks first ensures that the function only proceeds if conditions are met, preventing wasted work or vulnerabilities. It helps avoid unexpected behavior or attacks.
Click to reveal answer
beginner
In the Checks-Effects-Interactions pattern, what does 'effects' mean?
Effects refer to updating the contract's internal state, like changing balances or flags, after all checks pass but before interacting with external contracts.
Click to reveal answer
intermediate
What kind of vulnerabilities does the Checks-Effects-Interactions pattern help prevent?
It helps prevent reentrancy attacks, where an external contract calls back into the original contract before the state is updated, causing inconsistent or malicious behavior.
Click to reveal answer
beginner
Show the correct order of steps in the Checks-Effects-Interactions pattern.
1. Checks: Verify conditions (e.g., require statements). 2. Effects: Update contract state variables. 3. Interactions: Call external contracts or send funds.
Click to reveal answer
What is the first step in the Checks-Effects-Interactions pattern?
✗ Incorrect
The pattern starts by performing checks to ensure conditions are met before any state changes or interactions.
Why should state changes happen before interactions in this pattern?
✗ Incorrect
Updating state before interactions prevents attackers from exploiting reentrancy by calling back before state updates.
Which vulnerability is most directly mitigated by the Checks-Effects-Interactions pattern?
✗ Incorrect
The pattern is designed to prevent reentrancy attacks by controlling the order of operations.
What happens if you interact with external contracts before updating your state?
✗ Incorrect
Interacting first can allow external contracts to reenter and exploit the contract before state updates.
Which of these is NOT part of the Checks-Effects-Interactions pattern?
✗ Incorrect
Loops are not a step in this pattern; the pattern focuses on checks, effects, and interactions.
Explain the Checks-Effects-Interactions pattern and why it is important in smart contract security.
Think about the order of operations and how attackers might exploit the contract.
You got /4 concepts.
Describe a simple example scenario where following the Checks-Effects-Interactions pattern prevents a security problem.
Imagine sending money to a user and what could go wrong if you don't update balances first.
You got /4 concepts.