Security
This package provides the API for all Security modules.
For an overview of the module, read the Security guide.
The page covers the following modules:
- Initializable: a one-time initialization guard.
- Pausable: an emergency stop mechanism.
- Allowlist: a permit-list keyed by account identifier.
- Blocklist: a deny-list keyed by account identifier.
import "./node_modules/@openzeppelin/compact-contracts/security/Initializable";Use this module only at the top contract layer, and import it into at most one module per contract.
When two modules in the same directory both import Initializable, the compiler collapses their
_isInitialized flags into a single shared ledger slot
(compact#270): initializing one marks the other
as initialized. The OpenZeppelin modules do not import this module; each tracks its own _isInitialized flag inline.
Ledger
_isInitialized: Boolean
ledger
#Whether initialize has run. Guards against re-initialization
and against use before initialization.
Witnesses
None.
Circuits
initialize() → []
circuit
#Initializes the state thus ensuring the calling circuit can only be called once.
Requirements:
- Contract must not be initialized.
assertInitialized() → []
circuit
#Asserts that the contract has been initialized, throwing an error if not.
Requirements:
- Contract must be initialized.
assertNotInitialized() → []
circuit
#Asserts that the contract has not been initialized, throwing an error if it has.
Requirements:
- Contract must not be initialized.
import "./node_modules/@openzeppelin/compact-contracts/security/Pausable";Ledger
_isPaused: Boolean
ledger
#Whether the contract is paused. Consuming contracts gate
state-changing circuits on it via assertPaused / assertNotPaused.
Witnesses
None.
Circuits
isPaused() → Boolean
circuit
#Returns true if the contract is paused, and false otherwise.
assertPaused() → []
circuit
#Makes a circuit only callable when the contract is paused.
Requirements:
- Contract must be paused.
assertNotPaused() → []
circuit
#Makes a circuit only callable when the contract is not paused.
Requirements:
- Contract must not be paused.
_pause() → []
circuit
#Triggers a stopped state.
Requirements:
- Contract must not be paused.
_unpause() → []
circuit
#Lifts the pause on the contract.
Requirements:
- Contract must be paused.
import "./node_modules/@openzeppelin/compact-contracts/security/Allowlist";A minimal permit-list keyed by a Bytes<32> account identifier.
The mutators _allow and _disallow are ungated: the implementing contract must protect them with its own access control
and decides where assertAllowed applies.
Membership is public and the approved set is publicly enumerable.
Ledger
_allowed: Set<Bytes<32>>
ledger
#Approved accounts. Absent means not allowed.
Witnesses
None.
Circuits
isAllowed(account: Bytes<32>) → Boolean
circuit
#Returns whether account is currently allowed.
assertAllowed(account: Bytes<32>) → []
circuit
#Asserts that account is allowed. The composing contract
decides when this gate applies.
Requirements:
accountis a member of the allowlist.
_allow(account: Bytes<32>) → []
circuit
#Adds account to the allowlist.
_disallow(account: Bytes<32>) → []
circuit
#Removes account from the allowlist.
import "./node_modules/@openzeppelin/compact-contracts/security/Blocklist";A minimal deny-list keyed by a Bytes<32> account identifier.
The mutators _block and _unblock are ungated: the implementing contract must protect them with its own access control
and decides where assertNotBlocked applies.
Membership is public and the blocked set is publicly enumerable.
Ledger
_blocked: Set<Bytes<32>>
ledger
#Blocked accounts. Absent means not blocked.
Witnesses
None.
Circuits
isBlocked(account: Bytes<32>) → Boolean
circuit
#Returns whether account is currently blocked.
assertNotBlocked(account: Bytes<32>) → []
circuit
#Asserts that account is not blocked. The composing contract
decides when this gate applies.
Requirements:
accountis not a member of the blocklist.
_block(account: Bytes<32>) → []
circuit
#Adds account to the blocklist.
_unblock(account: Bytes<32>) → []
circuit
#Removes account from the blocklist.