Skip to main content
In Solana, all state is stored in accounts. Anchor provides strongly-typed account wrappers that automatically handle validation and deserialization.

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.
The Account&lt;'info, T&gt; 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.
The 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.
The Program type checks that the account is executable.

UncheckedAccount<‘info>

Raw AccountInfo with no automatic checks. Use with caution.
Always add a /// CHECK: doc comment explaining why the account doesn’t need checks.

Interface types

For Token-2022 compatibility, use interface types:

Account validation

Anchor provides constraints for automatic account validation:

Initialization constraints

Mutable accounts

Field validation

The 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:
This ensures accounts can’t be used after the instruction completes.

Complete example

Next steps

Account constraints

Complete reference of all account constraints

PDAs

Learn about Program Derived Addresses