Enum spl_token::instruction::TokenInstruction[][src]

#[repr(C)]
pub enum TokenInstruction {
Show variants InitializeMint { decimals: u8, mint_authority: Pubkey, freeze_authority: COption<Pubkey>, }, InitializeAccount, InitializeMultisig { m: u8, }, Transfer { amount: u64, }, Approve { amount: u64, }, Revoke, SetAuthority { authority_type: AuthorityType, new_authority: COption<Pubkey>, }, MintTo { amount: u64, }, Burn { amount: u64, }, CloseAccount, FreezeAccount, ThawAccount, TransferChecked { amount: u64, decimals: u8, }, ApproveChecked { amount: u64, decimals: u8, }, MintToChecked { amount: u64, decimals: u8, }, BurnChecked { amount: u64, decimals: u8, }, InitializeAccount2 { owner: Pubkey, },
}
Expand description

Instructions supported by the token program.

Variants

InitializeMint
Expand description

Initializes a new mint and optionally deposits all the newly minted tokens in an account.

The InitializeMint 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 mint to initialize.
  2. [] Rent sysvar
Show fields

Fields of InitializeMint

decimals: u8
Expand description

Number of base 10 digits to the right of the decimal place.

mint_authority: Pubkey
Expand description

The authority/multisignature to mint tokens.

freeze_authority: COption<Pubkey>
Expand description

The freeze authority/multisignature of the mint.

InitializeAccount
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 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
InitializeMultisig
Expand description

Initializes a multisignature account with N provided signers.

Multisignature accounts can used in place of any single owner/delegate accounts in any token instruction that require an owner/delegate to be present. The variant field represents the number of signers (M) required to validate this multisignature account.

The InitializeMultisig 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 multisignature account to initialize.
  2. [] Rent sysvar
  3. ..2+N. [] The signer accounts, must equal to N where 1 <= N <=
Show fields

Fields of InitializeMultisig

m: u8
Expand description

The number of signers (M) required to validate this multisignature account.

Transfer
Expand description

Transfers tokens from one account to another either directly or via a delegate. If this account is associated with the native mint then equal amounts of SOL and Tokens will be transferred to the destination account.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The source account.
  2. [writable] The destination account.
  3. [signer] The source account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The source account.
  2. [writable] The destination account.
  3. [] The source account’s multisignature owner/delegate.
  4. ..3+M [signer] M signer accounts.
Show fields

Fields of Transfer

amount: u64
Expand description

The amount of tokens to transfer.

Approve
Expand description

Approves a delegate. A delegate is given the authority over tokens on behalf of the source account’s owner.

Accounts expected by this instruction:

  • Single owner
  1. [writable] The source account.
  2. [] The delegate.
  3. [signer] The source account owner.
  • Multisignature owner
  1. [writable] The source account.
  2. [] The delegate.
  3. [] The source account’s multisignature owner.
  4. ..3+M [signer] M signer accounts
Show fields

Fields of Approve

amount: u64
Expand description

The amount of tokens the delegate is approved for.

Revoke
Expand description

Revokes the delegate’s authority.

Accounts expected by this instruction:

  • Single owner
  1. [writable] The source account.
  2. [signer] The source account owner.
  • Multisignature owner
  1. [writable] The source account.
  2. [] The source account’s multisignature owner.
  3. ..2+M [signer] M signer accounts
SetAuthority
Expand description

Sets a new authority of a mint or account.

Accounts expected by this instruction:

  • Single authority
  1. [writable] The mint or account to change the authority of.
  2. [signer] The current authority of the mint or account.
  • Multisignature authority
  1. [writable] The mint or account to change the authority of.
  2. [] The mint’s or account’s current multisignature authority.
  3. ..2+M [signer] M signer accounts
Show fields

Fields of SetAuthority

authority_type: AuthorityType
Expand description

The type of authority to update.

new_authority: COption<Pubkey>
Expand description

The new authority

MintTo
Expand description

Mints new tokens to an account. The native mint does not support minting.

Accounts expected by this instruction:

  • Single authority
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [signer] The mint’s minting authority.
  • Multisignature authority
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [] The mint’s multisignature mint-tokens authority.
  4. ..3+M [signer] M signer accounts.
Show fields

Fields of MintTo

amount: u64
Expand description

The amount of new tokens to mint.

Burn
Expand description

Burns tokens by removing them from an account. Burn does not support accounts associated with the native mint, use CloseAccount instead.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The account to burn from.
  2. [writable] The token mint.
  3. [signer] The account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The account to burn from.
  2. [writable] The token mint.
  3. [] The account’s multisignature owner/delegate.
  4. ..3+M [signer] M signer accounts.
Show fields

Fields of Burn

amount: u64
Expand description

The amount of tokens to burn.

CloseAccount
Expand description

Close an account by transferring all its SOL to the destination account. Non-native accounts may only be closed if its token amount is zero.

Accounts expected by this instruction:

  • Single owner
  1. [writable] The account to close.
  2. [writable] The destination account.
  3. [signer] The account’s owner.
  • Multisignature owner
  1. [writable] The account to close.
  2. [writable] The destination account.
  3. [] The account’s multisignature owner.
  4. ..3+M [signer] M signer accounts.
FreezeAccount
Expand description

Freeze an Initialized account using the Mint’s freeze_authority (if set).

Accounts expected by this instruction:

  • Single owner
  1. [writable] The account to freeze.
  2. [] The token mint.
  3. [signer] The mint freeze authority.
  • Multisignature owner
  1. [writable] The account to freeze.
  2. [] The token mint.
  3. [] The mint’s multisignature freeze authority.
  4. ..3+M [signer] M signer accounts.
ThawAccount
Expand description

Thaw a Frozen account using the Mint’s freeze_authority (if set).

Accounts expected by this instruction:

  • Single owner
  1. [writable] The account to freeze.
  2. [] The token mint.
  3. [signer] The mint freeze authority.
  • Multisignature owner
  1. [writable] The account to freeze.
  2. [] The token mint.
  3. [] The mint’s multisignature freeze authority.
  4. ..3+M [signer] M signer accounts.
TransferChecked
Expand description

Transfers tokens from one account to another either directly or via a delegate. If this account is associated with the native mint then equal amounts of SOL and Tokens will be transferred to the destination account.

This instruction differs from Transfer in that the token mint and decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [signer] The source account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [] The source account’s multisignature owner/delegate.
  5. ..4+M [signer] M signer accounts.
Show fields

Fields of TransferChecked

amount: u64
Expand description

The amount of tokens to transfer.

decimals: u8
Expand description

Expected number of base 10 digits to the right of the decimal place.

ApproveChecked
Expand description

Approves a delegate. A delegate is given the authority over tokens on behalf of the source account’s owner.

This instruction differs from Approve in that the token mint and decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Accounts expected by this instruction:

  • Single owner
  1. [writable] The source account.
  2. [] The token mint.
  3. [] The delegate.
  4. [signer] The source account owner.
  • Multisignature owner
  1. [writable] The source account.
  2. [] The token mint.
  3. [] The delegate.
  4. [] The source account’s multisignature owner.
  5. ..4+M [signer] M signer accounts
Show fields

Fields of ApproveChecked

amount: u64
Expand description

The amount of tokens the delegate is approved for.

decimals: u8
Expand description

Expected number of base 10 digits to the right of the decimal place.

MintToChecked
Expand description

Mints new tokens to an account. The native mint does not support minting.

This instruction differs from MintTo in that the decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Accounts expected by this instruction:

  • Single authority
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [signer] The mint’s minting authority.
  • Multisignature authority
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [] The mint’s multisignature mint-tokens authority.
  4. ..3+M [signer] M signer accounts.
Show fields

Fields of MintToChecked

amount: u64
Expand description

The amount of new tokens to mint.

decimals: u8
Expand description

Expected number of base 10 digits to the right of the decimal place.

BurnChecked
Expand description

Burns tokens by removing them from an account. BurnChecked does not support accounts associated with the native mint, use CloseAccount instead.

This instruction differs from Burn in that the decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The account to burn from.
  2. [writable] The token mint.
  3. [signer] The account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The account to burn from.
  2. [writable] The token mint.
  3. [] The account’s multisignature owner/delegate.
  4. ..3+M [signer] M signer accounts.
Show fields

Fields of BurnChecked

amount: u64
Expand description

The amount of tokens to burn.

decimals: u8
Expand description

Expected number of base 10 digits to the right of the decimal place.

InitializeAccount2
Expand description

Like InitializeAccount, but the owner pubkey is passed via instruction data rather than the accounts list. This variant may be preferable when using Cross Program Invocation from an instruction that does not need the owner’s AccountInfo otherwise.

Accounts expected by this instruction:

  1. [writable] The account to initialize.
  2. [] The mint this account will be associated with.
  3. [] Rent sysvar
Show fields

Fields of InitializeAccount2

owner: Pubkey
Expand description

The new account’s owner/multisignature.

Implementations

impl TokenInstruction[src]

pub fn unpack(input: &[u8]) -> Result<Self, ProgramError>[src]

Unpacks a byte buffer into a TokenInstruction.

pub fn pack(&self) -> Vec<u8>[src]

Packs a TokenInstruction into a byte buffer.

Trait Implementations

impl Clone for TokenInstruction[src]

fn clone(&self) -> TokenInstruction[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for TokenInstruction[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl PartialEq<TokenInstruction> for TokenInstruction[src]

fn eq(&self, other: &TokenInstruction) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &TokenInstruction) -> bool[src]

This method tests for !=.

impl StructuralPartialEq for TokenInstruction[src]

Auto Trait Implementations

Blanket Implementations

impl<T> AbiExample for T

pub default fn example() -> T

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V