Skip to main content

when_paused

Attribute Macro when_paused 

Source
#[when_paused]
Expand description

Adds a pause check at the beginning of the function that ensures the contract is paused.

This macro will inject a when_paused check at the start of the function body. If the contract is not paused, the function will return early with a panic.

§Requirement:

  • The first argument of the decorated function must be of type Env or &Env

§Example:

#[when_paused]
pub fn my_function(e: &Env) {
    // This code will only execute if the contract is paused
}