pub struct Context<'a, 'b, 'c, 'info, T> {
    pub program_id: &'a Pubkey,
    pub accounts: &'b mut T,
    pub remaining_accounts: &'c [AccountInfo<'info>],
    pub bumps: BTreeMap<String, u8>,
}
Expand description

Provides non-argument inputs to the program.

Example

pub fn set_data(ctx: Context<SetData>, age: u64, other_data: u32) -> Result<()> {
    // Set account data like this
    (*ctx.accounts.my_account).age = age;
    (*ctx.accounts.my_account).other_data = other_data;
    // or like this
    let my_account = &mut ctx.account.my_account;
    my_account.age = age;
    my_account.other_data = other_data;
    Ok(())
}

Fields

program_id: &'a Pubkey

Currently executing program id.

accounts: &'b mut T

Deserialized accounts.

remaining_accounts: &'c [AccountInfo<'info>]

Remaining accounts given but not deserialized or validated. Be very careful when using this directly.

bumps: BTreeMap<String, u8>

Bump seeds found during constraint validation. This is provided as a convenience so that handlers don’t have to recalculate bump seeds or pass them in as arguments.

Implementations

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.