Skip to content

Instantly share code, notes, and snippets.

@nathan-websculpt
Last active September 24, 2021 20:40
Show Gist options
  • Save nathan-websculpt/55b73bcd88df8eaa36f49e861c37e5b4 to your computer and use it in GitHub Desktop.
Save nathan-websculpt/55b73bcd88df8eaa36f49e861c37e5b4 to your computer and use it in GitHub Desktop.
This is an example Reentrancy Guard for teaching purposes
// 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;
}
}
@nathan-websculpt
Copy link
Author

Used as an example in This Blog Post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment