pub trait Accounts<'info, B>: ToAccountMetas + ToAccountInfos<'info> + Sized {
    // Required method
    fn try_accounts(
        program_id: &Pubkey,
        accounts: &mut &'info [AccountInfo<'info>],
        ix_data: &[u8],
        bumps: &mut B,
        reallocs: &mut BTreeSet<Pubkey>
    ) -> Result<Self, Error>;
}
Expand description

A data structure of validated accounts that can be deserialized from the input to a Solana program. Implementations of this trait should perform any and all requisite constraint checks on accounts to ensure the accounts maintain any invariants required for the program to run securely. In most cases, it’s recommended to use the Accounts derive macro to implement this trait.

Generics:

  • B: the type of the PDA bumps cache struct generated by the Accounts struct. For example,
pub struct Example<'info> {
    #[account(
        init,
        seeds = [...],
        bump,
    )]
    pub pda_1: UncheckedAccount<'info>,
    pub not_pda: UncheckedAccount<'info>,
}

generates:

pub struct ExampleBumps {
    pub pda_1: u8,
}

Required Methods§

fn try_accounts( program_id: &Pubkey, accounts: &mut &'info [AccountInfo<'info>], ix_data: &[u8], bumps: &mut B, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Self, Error>

Returns the validated accounts struct. What constitutes “valid” is program dependent. However, users of these types should never have to worry about account substitution attacks. For example, if a program expects a Mint account from the SPL token program in a particular field, then it should be impossible for this method to return Ok if any other account type is given–from the SPL token program or elsewhere.

program_id is the currently executing program. accounts is the set of accounts to construct the type from. For every account used, the implementation should mutate the slice, consuming the used entry so that it cannot be used again.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl<'info> Accounts<'info, AmountToUiAmountBumps> for AmountToUiAmount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut AmountToUiAmountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<AmountToUiAmount<'info>, Error>

§

impl<'info> Accounts<'info, ApproveBumps> for Approve<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut ApproveBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Approve<'info>, Error>

§

impl<'info> Accounts<'info, ApproveBumps> for Approve<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut ApproveBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Approve<'info>, Error>

§

impl<'info> Accounts<'info, ApproveCheckedBumps> for ApproveChecked<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut ApproveCheckedBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<ApproveChecked<'info>, Error>

§

impl<'info> Accounts<'info, BurnBumps> for Burn<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BurnBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Burn<'info>, Error>

§

impl<'info> Accounts<'info, BurnBumps> for Burn<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BurnBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Burn<'info>, Error>

§

impl<'info> Accounts<'info, CloseAccountBumps> for CloseAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut CloseAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<CloseAccount<'info>, Error>

§

impl<'info> Accounts<'info, CloseAccountBumps> for CloseAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut CloseAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<CloseAccount<'info>, Error>

§

impl<'info> Accounts<'info, CreateBumps> for Create<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut CreateBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Create<'info>, Error>

§

impl<'info> Accounts<'info, FreezeAccountBumps> for FreezeAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut FreezeAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<FreezeAccount<'info>, Error>

§

impl<'info> Accounts<'info, FreezeAccountBumps> for FreezeAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut FreezeAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<FreezeAccount<'info>, Error>

§

impl<'info> Accounts<'info, GetAccountDataSizeBumps> for GetAccountDataSize<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut GetAccountDataSizeBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<GetAccountDataSize<'info>, Error>

§

impl<'info> Accounts<'info, InitializeAccount3Bumps> for InitializeAccount3<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeAccount3Bumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeAccount3<'info>, Error>

§

impl<'info> Accounts<'info, InitializeAccount3Bumps> for InitializeAccount3<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeAccount3Bumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeAccount3<'info>, Error>

§

impl<'info> Accounts<'info, InitializeAccountBumps> for InitializeAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeAccount<'info>, Error>

§

impl<'info> Accounts<'info, InitializeAccountBumps> for InitializeAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeAccount<'info>, Error>

§

impl<'info> Accounts<'info, InitializeImmutableOwnerBumps> for InitializeImmutableOwner<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeImmutableOwnerBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeImmutableOwner<'info>, Error>

§

impl<'info> Accounts<'info, InitializeMint2Bumps> for InitializeMint2<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeMint2Bumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeMint2<'info>, Error>

§

impl<'info> Accounts<'info, InitializeMint2Bumps> for InitializeMint2<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeMint2Bumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeMint2<'info>, Error>

§

impl<'info> Accounts<'info, InitializeMintBumps> for InitializeMint<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeMintBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeMint<'info>, Error>

§

impl<'info> Accounts<'info, InitializeMintBumps> for InitializeMint<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeMintBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeMint<'info>, Error>

§

impl<'info> Accounts<'info, InitializeMintCloseAuthorityBumps> for InitializeMintCloseAuthority<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut InitializeMintCloseAuthorityBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<InitializeMintCloseAuthority<'info>, Error>

§

impl<'info> Accounts<'info, MintToBumps> for MintTo<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut MintToBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<MintTo<'info>, Error>

§

impl<'info> Accounts<'info, MintToBumps> for MintTo<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut MintToBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<MintTo<'info>, Error>

§

impl<'info> Accounts<'info, RevokeBumps> for Revoke<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut RevokeBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Revoke<'info>, Error>

§

impl<'info> Accounts<'info, RevokeBumps> for Revoke<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut RevokeBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Revoke<'info>, Error>

§

impl<'info> Accounts<'info, SetAuthorityBumps> for SetAuthority<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut SetAuthorityBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<SetAuthority<'info>, Error>

§

impl<'info> Accounts<'info, SetAuthorityBumps> for SetAuthority<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut SetAuthorityBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<SetAuthority<'info>, Error>

§

impl<'info> Accounts<'info, SyncNativeBumps> for SyncNative<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut SyncNativeBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<SyncNative<'info>, Error>

§

impl<'info> Accounts<'info, SyncNativeBumps> for SyncNative<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut SyncNativeBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<SyncNative<'info>, Error>

§

impl<'info> Accounts<'info, ThawAccountBumps> for ThawAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut ThawAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<ThawAccount<'info>, Error>

§

impl<'info> Accounts<'info, ThawAccountBumps> for ThawAccount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut ThawAccountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<ThawAccount<'info>, Error>

§

impl<'info> Accounts<'info, TransferBumps> for Transfer<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut TransferBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Transfer<'info>, Error>

§

impl<'info> Accounts<'info, TransferBumps> for Transfer<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut TransferBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<Transfer<'info>, Error>

§

impl<'info> Accounts<'info, TransferCheckedBumps> for TransferChecked<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut TransferCheckedBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<TransferChecked<'info>, Error>

§

impl<'info> Accounts<'info, TransferCheckedBumps> for TransferChecked<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut TransferCheckedBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<TransferChecked<'info>, Error>

§

impl<'info> Accounts<'info, UiAmountToAmountBumps> for UiAmountToAmount<'info>
where 'info: 'info,

§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &'info [AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut UiAmountToAmountBumps, __reallocs: &mut BTreeSet<Pubkey> ) -> Result<UiAmountToAmount<'info>, Error>

§

impl<'info, B, T> Accounts<'info, B> for Option<T>
where T: Accounts<'info, B>,

§

fn try_accounts( program_id: &Pubkey, accounts: &mut &'info [AccountInfo<'info>], ix_data: &[u8], bumps: &mut B, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Option<T>, Error>

Implementors§

source§

impl<'info> Accounts<'info, AttestationPermissionInitBumps> for AttestationPermissionInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, AttestationPermissionSetBumps> for AttestationPermissionSet<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, AttestationQueueAddMrEnclaveBumps> for AttestationQueueAddMrEnclave<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, AttestationQueueInitBumps> for AttestationQueueInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionCloseBumps> for FunctionClose<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionInitBumps> for FunctionInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionSetConfigBumps> for FunctionSetConfig<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionSetEscrowBumps> for FunctionSetEscrow<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionTriggerBumps> for FunctionTrigger<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionVerifyBumps> for FunctionVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestCloseBumps> for FunctionRequestClose<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestInitBumps> for FunctionRequestInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestInitAndTriggerBumps> for FunctionRequestInitAndTrigger<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestSetConfigBumps> for FunctionRequestSetConfig<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestTriggerBumps> for FunctionRequestTrigger<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRequestVerifyBumps> for FunctionRequestVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRoutineInitBumps> for FunctionRoutineInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionRoutineVerifyBumps> for FunctionRoutineVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, ServiceRequestQuoteVerifyBumps> for ServiceRequestQuoteVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, FunctionServiceVerifyBumps> for FunctionServiceVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VerifierHeartbeatBumps> for VerifierHeartbeat<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VerifierInitBumps> for VerifierInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VerifierQuoteRotateBumps> for VerifierQuoteRotate<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VerifierQuoteVerifyBumps> for VerifierQuoteVerify<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, WalletFundBumps> for WalletFund<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, WalletInitBumps> for WalletInit<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, WalletWithdrawBumps> for WalletWithdraw<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, PermissionSetBumps> for PermissionSet<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfCloseBumps> for VrfClose<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfLiteCloseBumps> for VrfLiteClose<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfLiteRequestRandomnessBumps> for VrfLiteRequestRandomness<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfPoolRemoveBumps> for VrfPoolRemove<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfPoolRequestRandomnessBumps> for VrfPoolRequestRandomness<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfRequestRandomnessBumps> for VrfRequestRandomness<'info>
where 'info: 'info,

source§

impl<'info> Accounts<'info, VrfSetCallbackBumps> for VrfSetCallback<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AdvanceNonceAccountBumps> for AdvanceNonceAccount<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AllocateBumps> for Allocate<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AllocateWithSeedBumps> for AllocateWithSeed<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AssignBumps> for Assign<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AssignWithSeedBumps> for AssignWithSeed<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, AuthorizeNonceAccountBumps> for AuthorizeNonceAccount<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, CreateAccountBumps> for CreateAccount<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, CreateAccountWithSeedBumps> for CreateAccountWithSeed<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, CreateNonceAccountBumps> for CreateNonceAccount<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, CreateNonceAccountWithSeedBumps> for CreateNonceAccountWithSeed<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, TransferBumps> for Transfer<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, TransferWithSeedBumps> for TransferWithSeed<'info>
where 'info: 'info,

§

impl<'info> Accounts<'info, WithdrawNonceAccountBumps> for WithdrawNonceAccount<'info>
where 'info: 'info,

§

impl<'info, B> Accounts<'info, B> for AccountInfo<'info>

§

impl<'info, B> Accounts<'info, B> for Signer<'info>

§

impl<'info, B> Accounts<'info, B> for SystemAccount<'info>

§

impl<'info, B> Accounts<'info, B> for UncheckedAccount<'info>

§

impl<'info, B, T> Accounts<'info, B> for Box<T>
where T: Accounts<'info, B>,

§

impl<'info, B, T> Accounts<'info, B> for Vec<T>
where T: Accounts<'info, B>,

§

impl<'info, B, T> Accounts<'info, B> for Account<'info, T>

§

impl<'info, B, T> Accounts<'info, B> for AccountLoader<'info, T>
where T: ZeroCopy + Owner,

§

impl<'info, B, T> Accounts<'info, B> for Interface<'info, T>
where T: CheckId,

§

impl<'info, B, T> Accounts<'info, B> for InterfaceAccount<'info, T>
where T: AccountSerialize + AccountDeserialize + CheckOwner + Clone,

§

impl<'info, B, T> Accounts<'info, B> for Program<'info, T>
where T: Id,

§

impl<'info, B, T> Accounts<'info, B> for Sysvar<'info, T>
where T: Sysvar,