What is the Reentrancy Guard Pattern in blockchain smart contracts?
It is a technique used to prevent a function from being called again before the first call finishes, stopping attacks where a contract repeatedly calls itself to drain funds.
Click to reveal answer
beginner
Why is reentrancy a problem in smart contracts?
Because it allows attackers to repeatedly enter a function before the previous execution finishes, potentially causing unexpected behavior like multiple withdrawals.
Click to reveal answer
intermediate
How does a bool locked variable help in implementing a reentrancy guard?
It acts like a lock: when a function starts, it sets locked = true. If the function is called again before finishing, it sees the lock and stops execution.
Click to reveal answer
intermediate
What Solidity keyword is commonly used to create a reentrancy guard modifier?
The modifier keyword is used to create reusable code that can check and set the lock before running the function body.
Click to reveal answer
advanced
Give a simple example of a reentrancy guard modifier in Solidity.