Skip to main content
Account constraints provide automatic validation and security checks.

Initialization constraints

init

Initialize a new account.
Required with:
  • payer - Who pays for the account
  • space - Account size in bytes

init_if_needed

Initialize only if the account doesn’t exist.

Mutability constraints

mut

Mark account as mutable.

Validation constraints

has_one

Validate an account field matches another account.
Checks: data.authority == authority.key()

constraint

Custom validation expression.

PDA constraints

seeds

Validate PDA derivation.

bump

Specify bump seed for PDA.

Closing constraints

close

Close account and return lamports.

Reallocation constraints

realloc

Change account size.

Token constraints

For SPL token accounts:
See SPL Integrations for token constraint details.

Complete reference

See the source code for all constraints.