> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/web3-security-research/secureum/epoch-0/slot-2-solidity-101/openzeppelin-pausable.md).

# OpenZeppelin Pausable

## OpenZeppelin Doc

{% embed url="<https://docs.openzeppelin.com/contracts/4.x/api/security#Pausable>" %}
Pausable
{% endembed %}

<mark style="color:red;">**Contract module which allows children to implement an emergency stop mechanism that can be triggered by an authorized account.**</mark>

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

{% embed url="<https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/Pausable.sol>" %}
Pausable.sol
{% endembed %}

### State Variables and Constants

There is only one state variable in this contract:

```solidity
bool private _paused;
```

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

### Modifiers

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

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

### \_pause() and \_unpause()

```solidity
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:

{% embed url="<https://github.com/pashov/audits/blob/master/solo/ParcelPayroll-security-review.md#m-03-contract-inherits-from-pausable-but-does-not-expose-pausingunpausing-functionality>" %}

<figure><img src="/files/accdVEjShjkuSPRJx9pc" alt=""><figcaption></figcaption></figure>
