Account types
Anchor provides several account types that handle common validation patterns:Account<‘info, T>
The most common account type that wraps a custom account type with automatic validation.Account<'info, T> type automatically:
- Deserializes the account data into type
T - Checks the account owner matches the program ID
- Validates the account discriminator matches type
T
Signer<‘info>
Verifies that an account signed the transaction.Signer type automatically checks that authority.is_signer is true.
SystemAccount<‘info>
Represents a native Solana account owned by the System Program.Program type
Verifies that an account is an executable program.Program type checks that the account is executable.
UncheckedAccount<‘info>
RawAccountInfo with no automatic checks. Use with caution.
Interface types
For Token-2022 compatibility, use interface types:Account validation
Anchor provides constraints for automatic account validation:Initialization constraints
Mutable accounts
Field validation
has_one = authority constraint checks that my_account.authority == authority.key().
PDA validation
Accessing account data
Access account fields directly through the validated account:Account lifetime
The'info lifetime indicates that account references are valid for the duration of the instruction:
Complete example
Next steps
Account constraints
Complete reference of all account constraints
PDAs
Learn about Program Derived Addresses