Skip to main content
The PausableCancellable is an abstract utility contract that provides pause and cancel functionality for emergency controls and state management in campaigns and treasuries.

Overview

Purpose

  • Emergency Controls: Allow pausing campaigns in emergencies
  • Cancellation Support: Permanent cancellation capability
  • State Management: Track paused and cancelled states
  • Reusable: Can be inherited by any contract needing these states
  • Safe Defaults: Prevents operations when paused/cancelled

State Variables

Functions

State Queries

Paused

Returns:
  • True if contract is paused

Cancelled

Returns:
  • True if contract is cancelled

State Management

Pause

Parameters:
  • reason: Reason for pausing
Effects:
  • Sets _paused to true
  • Emits Paused event
  • Stops most operations
Requirements:
  • Contract must not be paused
  • Contract must not be cancelled

Unpause

Parameters:
  • reason: Reason for unpausing
Effects:
  • Sets _paused to false
  • Emits Unpaused event
  • Resumes operations
Requirements:
  • Contract must be paused

Cancel

Parameters:
  • reason: Reason for cancellation
Effects:
  • Sets _cancelled to true
  • Unpauses if paused
  • Emits Cancelled event
  • Prevents future operations
Requirements:
  • Contract must not be cancelled
  • Cancellation is permanent and irreversible

Modifiers

When Not Paused

Effect:
  • Reverts if contract is paused
  • Used on functions that should be disabled when paused

When Paused

Effect:
  • Reverts if contract is not paused
  • Used on functions that should only work when paused

When Not Cancelled

Effect:
  • Reverts if contract is cancelled
  • Used on most functions to prevent operations

When Cancelled

Effect:
  • Reverts if contract is not cancelled
  • Used on functions that should only work when cancelled

Events

Paused

Emitted when: Contract is paused Includes: Account that paused, reason for pausing

Unpaused

Emitted when: Contract is unpaused Includes: Account that unpaused, reason

Cancelled

Emitted when: Contract is cancelled Includes: Account that cancelled, reason

Errors

PausedError

Thrown when: Operation attempted while paused

NotPausedError

Thrown when: Unpause attempted when not paused

CancelledError

Thrown when: Operation attempted when cancelled

CannotCancel

Thrown when: Cancel attempted on already-cancelled contract

Usage Examples

Using State Modifiers

Checking State

Emergency Pause

Cancellation

Integration

With CampaignInfo

With BaseTreasury

State Transitions

Paused

Cancelled

Security Considerations

Permanent Cancellation

  • Cancellation is irreversible
  • No way to recover from cancelled state
  • All operations permanently disabled
  • Use only when absolutely necessary

Pause vs Cancel

  • Pause: Temporary, can be unpaused
  • Cancel: Permanent, cannot be undone
  • Choose carefully which to use

Access Control

  • Only authorized accounts can pause/unpause/cancel
  • Typically protocol admins can pause
  • Campaign owners or protocol admins can cancel

Best Practices

Use Clear Reasons

Monitor State Changes

Frontend State Checks

Next Steps