Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Emergency Stop Pattern

1 min read
Pronunciation
[ih-MUR-juhn-see stop pat-ern]
Analogy
Think of an emergency stop like a train’s dead man’s switch—it immediately stops all operations when triggered to prevent accidents.
Definition
A smart contract design that allows authorized parties to halt contract operations in case of detected vulnerabilities or anomalous behavior.
Key Points Intro
The Emergency Stop Pattern enables rapid response through:
Key Points

Circuit breaker variable: A boolean flag (e.g., `stopped`) controlling function execution.

Modifier integration: Functions check `require(!stopped)` before critical logic.

Authorized control: Only designated roles (owner, guardian) can toggle the flag.

Fail-safe mode: Halts state‑changing operations while allowing withdrawals or refunds.

Example
``` modifier whenRunning { require(!stopped, "Paused"); _; } function transfer(...) external whenRunning { ... } function toggleEmergency() external onlyOwner { stopped = !stopped; } ```
Technical Deep Dive
Implement a `stopped` state variable and a `whenRunning` modifier. Wrap all mutative functions with the modifier. Provide `toggleEmergency()` guarded by an `onlyOwner` or multisig role. Ensure withdrawal or refund functions use a separate `whenStopped` modifier if users must recover funds while paused.
Security Warning
If the owner key is compromised, an attacker can freeze the contract indefinitely; use multisig or time‑lock on toggles.
Caveat
Pausing too broadly can lock out legitimate use; carefully choose which functions respect the stop flag.

Emergency Stop Pattern - Related Articles

No related articles for this term.