abi Pausable {
    /// Pauses the contract.
    ///
    /// # Additional Information
    ///
    /// It is highly encouraged to use the Ownership Library in order to lock this
    /// function to a single administrative user.
    ///
    /// # Number of Storage Accesses
    ///
    /// * Writes: `1`
    ///
    /// # Examples
    ///
    /// ```sway
    /// use sway_libs::pausable::Pausable;
    ///
    /// fn foo(contract_id: ContractId) {
    ///     let pausable_abi = abi(Pausable, contract_id);
    ///     pausable_abi.pause();
    ///     assert(pausable_abi.is_paused());
    /// }
    /// ```
    #[storage(write)]
    fn pause();
    /// Returns whether the contract is paused.
    ///
    /// # Returns
    ///
    /// * [bool] - The pause state for the contract.
    ///
    /// # Number of Storage Accesses
    ///
    /// * Reads: `1`
    ///
    /// # Examples
    ///
    /// ```sway
    /// use sway_libs::pausable::Pausable;
    ///
    /// fn foo(contract_id: ContractId) {
    ///     let pausable_abi = abi(Pausable, contract_id);
    ///     assert(!pausable_abi.is_paused());
    /// }
    /// ```
    #[storage(read)]
    fn is_paused() -> bool;
    /// Unpauses the contract.
    ///
    /// # Additional Information
    ///
    /// It is highly encouraged to use the Ownership Library in order to lock this
    /// function to a single administrative user.
    ///
    /// # Number of Storage Accesses
    ///
    /// * Writes: `1`
    ///
    /// # Examples
    ///
    /// ```sway
    /// use sway_libs::pausable::Pausable;
    ///
    /// fn foo(contract_id: ContractId) {
    ///     let pausable_abi = abi(Pausable, contract_id);
    ///     pausable_abi.unpause();
    ///     assert(!pausable_abi.is_paused());
    /// }
    /// ```
    #[storage(write)]
    fn unpause();
}

Required Methods

Pauses the contract.

Additional Information

It is highly encouraged to use the Ownership Library in order to lock this
function to a single administrative user.

Number of Storage Accesses

  • Writes: 1

Examples

use sway_libs::pausable::Pausable;

fn foo(contract_id: ContractId) {
    let pausable_abi = abi(Pausable, contract_id);
    pausable_abi.pause();
    assert(pausable_abi.is_paused());
}

Returns whether the contract is paused.

Returns

  • [bool] - The pause state for the contract.

Number of Storage Accesses

  • Reads: 1

Examples

use sway_libs::pausable::Pausable;

fn foo(contract_id: ContractId) {
    let pausable_abi = abi(Pausable, contract_id);
    assert(!pausable_abi.is_paused());
}

Unpauses the contract.

Additional Information

It is highly encouraged to use the Ownership Library in order to lock this
function to a single administrative user.

Number of Storage Accesses

  • Writes: 1

Examples

use sway_libs::pausable::Pausable;

fn foo(contract_id: ContractId) {
    let pausable_abi = abi(Pausable, contract_id);
    pausable_abi.unpause();
    assert(!pausable_abi.is_paused());
}