Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cryptonomicon46/8148777241be92b3bda536f0cdff44a5 to your computer and use it in GitHub Desktop.

Select an option

Save cryptonomicon46/8148777241be92b3bda536f0cdff44a5 to your computer and use it in GitHub Desktop.
Function Modifiers and reentrancy guard
enum MintStage {
MintLive,
MintEnded
}
MintStage mintStage;
modifier mintTimedTransitions() {
if (block.timestamp > endAt)
nextMintStage();
_;
}
modifier atMintStage(MintStage mintStage_) {
if (mintStage != mintStage_) revert FunctionInvalidAtThisStage();
_;
}
//NoReentrant Call function modifier
bool locked;
modifier noReentrancy() {
require(!locked,"Reentrant Call");
locked = true;
_;
locked = false;
_;
}
function nextMintStage() internal {
mintStage = MintStage(uint(mintStage)+1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment