Previous Versionsv0.3.0Utilities

Pausable

Outdated Version

You're viewing an older version (v0.3.0) The latest documentation is available for the current version. Click here to visit latest version.

Source Code

Purpose

Allows contracts to be paused and unpaused by authorized accounts.

This utility contract can be used with any token standard (fungible, non-fungible, multi-token).

Design

To make it easier to spot when inspecting the code, we turned this simple functionality into a macro that can annotate your smart contract functions.

An example:

#[when_paused]
pub fn emergency_reset(e: &Env) {
    e.storage().instance().set(&DataKey::Counter, &0);
}

Which will expand into the below code:

pub fn emergency_reset(e: &Env) {
    when_paused(e);

    e.storage().instance().set(&DataKey::Counter, &0);
}

On this page