Account Types
Anchor Account Type Examples
Minimal reference examples for Anchor account types.
See the account types source code for implementation details.
Account Types
Account<'info, T>
Description: Account container that checks ownership on deserialization
Examples: Github
|
Solpg
AccountInfo<'info>
Description: AccountInfo can be used as a type but Unchecked Account should be
used instead
Examples: Github
|
Solpg
AccountLoader<'info, T>
Description: Type facilitating on demand zero copy deserialization
Examples: Github
|
Solpg
Box<Account<'info, T>>
Description: Box type to save stack space
Examples: Github
|
Solpg
Interface<'info, T>
Description: Type validating that the account is one of a set of given
Programs
Examples: Github
|
Solpg
InterfaceAccount<'info, T>
Description: Account container that checks ownership on deserialization
Examples: Github
|
Solpg
Option<Account<'info, T>>
Description: Option type for optional accounts
Examples: Github
|
Solpg
Program<'info, T>
Description: Type validating that the account is the given Program
Examples: Github
|
Solpg
Signer<'info>
Description: Type validating that the account signed the transaction
Examples: Github
|
Solpg
SystemAccount<'info>
Description: Type validating that the account is owned by the system program
Examples: Github
|
Solpg
Sysvar<'info, T>
Description: Type validating that the account is a sysvar and deserializing it
Examples: Github
|
Solpg
UncheckedAccount<'info>
Description: Explicit wrapper for AccountInfo types to emphasize that no checks
are performed
Examples: Github
|
Solpg
Migration<'info, From, To>
Description: Account container that handles schema migrations from one account type (From) to another (To). During deserialization, the account must be in the From format. On instruction exit, the account must be migrated to the To format, which is then serialized. Typically used with the realloc constraint to resize accounts during migration.
Checks:
Account.info.owner == From::owner()- Account is initialized (not owned by system program with 0 lamports)
- Account deserializes as
Fromtype
Usage patterns: