Skip to main content

InitializeAccount

Struct InitializeAccount 

Source
pub struct InitializeAccount<'account> {
    pub account: &'account AccountView,
    pub mint: &'account AccountView,
    pub owner: &'account AccountView,
    pub rent_sysvar: &'account AccountView,
}
Expand description

Initializes a new account to hold tokens. If this account is associated with the native mint then the token balance of the initialized account will be equal to the amount of SOL in the account. If this account is associated with another mint, that mint must be initialized before this command can succeed.

The super::InitializeAccount instruction requires no signers and MUST be included within the same Transaction as the system program’s CreateAccount instruction that creates the account being initialized. Otherwise another party can acquire ownership of the uninitialized account.

Accounts expected by this instruction:

  1. [writable] The account to initialize.
  2. [] The mint this account will be associated with.
  3. [] The new account’s owner/multisignature.
  4. [] Rent sysvar.

Fields§

§account: &'account AccountView

The account to initialize.

§mint: &'account AccountView

The mint this account will be associated with.

§owner: &'account AccountView

The new account’s owner/multisignature.

§rent_sysvar: &'account AccountView

Rent sysvar.

Implementations§

Source§

impl<'account> InitializeAccount<'account>

Source

pub const DISCRIMINATOR: u8 = 1

Source

pub const ACCOUNTS_LEN: usize = 4

Expected number of accounts.

Source

pub const DATA_LEN: usize = 1

Instruction data length:

  • discriminator (1 byte)
Source

pub fn new( account: &'account AccountView, mint: &'account AccountView, owner: &'account AccountView, rent_sysvar: &'account AccountView, ) -> Self

Source

pub fn invoke(&self) -> ProgramResult

Trait Implementations§

Source§

impl CpiWriter for InitializeAccount<'_>

Source§

fn write_accounts<'cpi>( &self, accounts: &mut [MaybeUninit<CpiAccount<'cpi>>], ) -> Result<usize, ProgramError>
where Self: 'cpi,

Writes the AccountViews required by this instruction into the provided slice. Read more
Source§

fn write_instruction_accounts<'cpi>( &self, accounts: &mut [MaybeUninit<InstructionAccount<'cpi>>], ) -> Result<usize, ProgramError>
where Self: 'cpi,

Writes the InstructionAccounts required by this instruction into the provided slice. Read more
Source§

fn write_instruction_data( &self, data: &mut [MaybeUninit<u8>], ) -> Result<usize, ProgramError>

Writes the instruction data for this instruction into the provided slice. Read more
Source§

impl IntoBatch for InitializeAccount<'_>

Source§

fn into_batch<'account, 'state>( self, batch: &mut Batch<'account, 'state>, ) -> ProgramResult
where Self: 'account + 'state,

Serializes self into the provided batch.

Auto Trait Implementations§

§

impl<'account> Freeze for InitializeAccount<'account>

§

impl<'account> RefUnwindSafe for InitializeAccount<'account>

§

impl<'account> !Send for InitializeAccount<'account>

§

impl<'account> !Sync for InitializeAccount<'account>

§

impl<'account> Unpin for InitializeAccount<'account>

§

impl<'account> UnsafeUnpin for InitializeAccount<'account>

§

impl<'account> UnwindSafe for InitializeAccount<'account>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.