Prevent reentrancy attacks using ReentrancyGuard.sol
There is a type of attack pattern where an attacker can call the function of a contract repeatedly. This is called a reentrancy attack. Using these types of attacks, an attacker may steal funds from the contract or perform unsafe operations on it. To prevent these types of attacks, the ReentrancyGuard.sol contract is used, which ensures that a function should be called only once per transaction.
However, it is the developer's responsibility to write code that isn't prone to reentrancy attacks. If there is still a chance of reentrancy attacks that cannot be stopped by code, then the modifier provided by this contract could be helpful.
The OpenZeppelin contract present at Chapter09/openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access