Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

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.
Start your free trial

You might also like

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content