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

#[repr(C)]pub enum TokenInstruction {
    InitializeMint {
        amount: u64,
        decimals: u8,
    },
    InitializeAccount,
    InitializeMultisig {
        m: u8,
    },
    Transfer {
        amount: u64,
    },
    Approve {
        amount: u64,
    },
    Revoke,
    SetOwner,
    MintTo {
        amount: u64,
    },
    Burn {
        amount: u64,
    },
    CloseAccount,
}

Instructions supported by the token program.

Variants

InitializeMint

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 CreateInstruction 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.
    • If supply is non-zero: [writable] The account to hold all the newly minted tokens.
    • If supply is zero: [] The owner/multisignature of the mint.
  2. [] (optional) The owner/multisignature of the mint if supply is non-zero, if present then further minting is supported.

Fields of InitializeMint

amount: u64

Initial amount of tokens to mint.

decimals: u8

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

InitializeAccount

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.

The InitializeAccount instruction requires no signers and MUST be included within the same Transaction as the system program's CreateInstruction 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.
InitializeMultisig

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 CreateInstruction 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. ..1+N. [] The signer accounts, must equal to N where 1 <= N <= 11.

Fields of InitializeMultisig

m: u8

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

Transfer

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.

Fields of Transfer

amount: u64

The amount of tokens to transfer.

Approve

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

Fields of Approve

amount: u64

The amount of tokens the delegate is approved for.

Revoke

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
SetOwner

Sets a new owner of a mint or account.

Accounts expected by this instruction:

  • Single owner
  1. [writable] The mint or account to change the owner of.
  2. [] The new owner/delegate/multisignature.
  3. [signer] The owner of the mint or account.
  • Multisignature owner
  1. [writable] The mint or account to change the owner of.
  2. [] The new owner/delegate/multisignature.
  3. [] The mint's or account's multisignature owner.
  4. ..3+M '[signer]' M signer accounts
MintTo

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

Accounts expected by this instruction:

  • Single owner
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [signer] The mint's owner.
  • Multisignature owner
  1. [writable] The mint.
  2. [writable] The account to mint tokens to.
  3. [] The mint's multisignature owner.
  4. ..3+M '[signer]' M signer accounts.

Fields of MintTo

amount: u64

The amount of new tokens to mint.

Burn

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. [signer] The account's owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The account to burn from.
  2. [] The account's multisignature owner/delegate.
  3. ..2+M '[signer]' M signer accounts.

Fields of Burn

amount: u64

The amount of tokens to burn.

CloseAccount

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.

Implementations

impl TokenInstruction[src]

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

Unpacks a byte buffer into a TokenInstruction.

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

Packs a TokenInstruction into a byte buffer.

Trait Implementations

impl Clone for TokenInstruction[src]

impl Debug for TokenInstruction[src]

impl PartialEq<TokenInstruction> for TokenInstruction[src]

impl StructuralPartialEq for TokenInstruction[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.

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.