Last active
September 24, 2021 20:40
-
-
Save nathan-websculpt/55b73bcd88df8eaa36f49e861c37e5b4 to your computer and use it in GitHub Desktop.
This is an example Reentrancy Guard for teaching purposes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract ReentrancyGuard { | |
bool private guardLocked; | |
modifier noReentry() { | |
require(!guardLocked, "Prevented by noReentry in ReentrancyGuard"); | |
guardLocked = true; | |
_; | |
guardLocked = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used as an example in This Blog Post