> ## Documentation Index
> Fetch the complete documentation index at: https://docs.theblockchainlibrary.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pausable Emergency Stop

> An emergency stop / circuit breaker pattern that lets authorized roles pause contract operations.

# Pausable Emergency Stop

An emergency stop / circuit breaker pattern that lets authorized roles pause contract operations.

An emergency stop / circuit breaker pattern that lets authorized roles pause contract operations.

## Explanation

The Pausable contract provides whenNotPaused and whenPaused modifiers. In an emergency, the owner can pause the contract to prevent withdrawals while a fix is deployed. This is a critical security pattern for DeFi.

## Code

```solidity theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract PausableToken is Pausable, Ownable {
    mapping(address => uint256) public balances;

    function deposit() external payable whenNotPaused {
        balances[msg.sender] += msg.value;
    }

    function withdraw(uint256 amount) external whenNotPaused {
        require(balances[msg.sender] >= amount, "Insufficient");
        balances[msg.sender] -= amount;
        payable(msg.sender).transfer(amount);
    }

    function pause() external onlyOwner { _pause(); }
    function unpause() external onlyOwner { _unpause(); }
}
```

***

**Canonical knowledge ID:** `code-example:pausable-emergency-stop`
