OpenZeppelin Pausable

OpenZeppelin Doc

Contract module which allows children to implement an emergency stop mechanism that can be triggered by an authorized account.

This module is used through inheritance. It will make available the modifiers whenNotPaused and whenPaused, which can be applied to the functions of your contract. Note that they will not be pausable by simply including this module, only once the modifiers are put in place.

OpenZeppelin Pausable

State Variables and Constants

There is only one state variable in this contract:

bool private _paused;

Note that when a contract inherits Pausable, _paused will be stored in storage slot 0.

Modifiers

modifier whenNotPaused() {
    _requireNotPaused();
    _;
}

modifier whenPaused() {
    _requirePaused();
    _;
}

_pause() and _unpause()

function _pause() internal virtual whenNotPaused {
    _paused = true;
    emit Paused(_msgSender());
}
    
function _unpause() internal virtual whenPaused {
    _paused = false;
    emit Unpaused(_msgSender());
}

Note that these two functios are internal functions. If you want to let admin pause the contract externally, you have to implement separate external functions. I learnt this fact from pashov's audit report:

Last updated