Security

This crate provides components to handle common security-related tasks.

Initializable

InitializableComponent

use openzeppelin_security::InitializableComponent;

Component enabling one-time initialization for contracts.

Embeddable Implementations
InitializableImpl
Internal Implementations
InternalImpl

Embeddable functions

is_initialized(self: @ComponentState) → bool external

Returns whether the contract has been initialized.

Internal functions

initialize(ref self: ComponentState) internal

Initializes the contract. Can only be called once.

Requirements:

  • the contract must not have been initialized before.

Pausable

PausableComponent

use openzeppelin_security::PausableComponent;

Component to implement an emergency stop mechanism.

Embeddable Implementations
PausableImpl

Embeddable functions

is_paused(self: @ComponentState) → bool external

Returns whether the contract is currently paused.

Internal functions

assert_not_paused(self: @ComponentState) internal

Panics if the contract is paused.

assert_paused(self: @ComponentState) internal

Panics if the contract is not paused.

pause(ref self: ComponentState) internal

Pauses the contract.

Requirements:

  • the contract must not be paused.

Emits a Paused event.

unpause(ref self: ComponentState) internal

Unpauses the contract.

Requirements:

  • the contract must be paused.

Emits an Unpaused event.

Events

Paused(account: ContractAddress) event

Emitted when the contract is paused by account.

Unpaused(account: ContractAddress) event

Emitted when the contract is unpaused by account.

ReentrancyGuard

ReentrancyGuardComponent

use openzeppelin_security::ReentrancyGuardComponent;

Component to help prevent reentrant calls.

Internal Implementations
InternalImpl

Internal functions

start(ref self: ComponentState) internal

Prevents a contract’s function from calling itself or another protected function, directly or indirectly.

Requirements:

  • the guard must not be currently enabled.

end(ref self: ComponentState) internal

Removes the reentrant guard.