Solana.SPL.Token (Solana.SPL v0.1.0) View Source

Functions for interacting with Solana's Token Program.

Link to this section Summary

Types

t()

Token account metadata.

Functions

Creates an instruction to approves a delegate.

Creates an instruction to burn tokens by removing them from an account.

The size of a serialized token account.

Creates an instruction to close an account by transferring all its SOL to the destination account.

Creates an instruction to freeze an initialized account using the mint's freeze_authority (if set).

The Token Program's ID.

Creates the instructions which initialize a new account to hold tokens.

Creates an instruction to mints new tokens to an account.

Creates an instruction to revoke a previously approved delegate's authority to make transfers.

Creates an instruction to set a new authority for a mint or account.

Creates an instruction to thaw a frozen account using the mint's freeze_authority (if set).

Creates an instruction to transfer tokens from one account to another either directly or via a delegate.

Link to this section Types

Specs

t() :: %Solana.SPL.Token{
  amount: non_neg_integer(),
  close_authority: Solana.key() | nil,
  delegate: Solana.key() | nil,
  delegated_amount: non_neg_integer(),
  frozen?: boolean(),
  initialized?: boolean(),
  mint: Solana.key(),
  native?: boolean(),
  owner: Solana.key(),
  rent_exempt_reserve: non_neg_integer() | nil
}

Token account metadata.

Link to this section Functions

Creates an instruction to approves a delegate.

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

If you want to check the token's mint and decimals, set the checked? option to true and provide the mint and decimals options.

Options

  • :source - Required. The account to send tokens from

  • :delegate - Required. The account authorized to perform a transfer of tokens from source

  • :owner - Required. The account which owns source

  • :multi_signers - signing accounts if the owner is a Solana.SPL.Token.MultiSig account

  • :amount - Required. The maximum number of tokens that delegate can send on behalf of source

  • :checked? - whether or not to check the token mint and decimals; may be useful when creating transactions offline or within a hardware wallet. The default value is false.

  • :decimals - The number of decimals in the amount. Only used if checked? is true.

  • :mint - The mint account for from and to. Only used if checked? is true.

Creates an instruction to burn tokens by removing them from an account.

burn/1 does not support accounts associated with the native mint, use close_account/1 instead.

If you want to check the token's mint and decimals, set the checked? option to true and provide the decimals option.

Options

  • :token - Required. The token account which will have its tokens burned

  • :mint - Required. The mint account which will burn the tokens

  • :owner - Required. the owner of token

  • :amount - Required. amount of tokens to burn

  • :multi_signers - signing accounts if the owner is a Solana.SPL.Token.MultiSig account

  • :checked? - whether or not to check the token mint and decimals; may be useful when creating transactions offline or within a hardware wallet. The default value is false.

  • :decimals - The number of decimals in the amount. Only used if checked? is true.

Specs

byte_size() :: pos_integer()

The size of a serialized token account.

Creates an instruction to close an account by transferring all its SOL to the destination account.

A non-native account may only be closed if its token amount is zero.

Options

  • :to_close - Required. The account to close

  • :destination - Required. The account which will receive the remaining balance of to_close

  • :authority - Required. the account close authority for to_close

  • :multi_signers - signing accounts if the authority is a Solana.SPL.Token.MultiSig account

Creates an instruction to freeze an initialized account using the mint's freeze_authority (if set).

Options

  • :to_freeze - Required. The account to freeze

  • :mint - Required. The mint account for to_freeze

  • :authority - Required. the freeze authority for mint

  • :multi_signers - signing accounts if the authority is a Solana.SPL.Token.MultiSig account

Specs

from_account_info(info :: map()) :: t() | :error

Translates the result of a Solana.RPC.Request.get_account_info/2 into a Solana.SPL.Token.t/0.

Specs

id() :: binary()

The Token Program's ID.

Creates the instructions which initialize 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.

All instructions must be executed as part of the same transaction. Otherwise another party can acquire ownership of the uninitialized account.

Options

  • :payer - Required. The account that will pay for the token account creation

  • :balance - Required. The lamport balance the token account should have

  • :mint - Required. The mint of the newly-created token account

  • :owner - Required. The owner of the newly-created token account

  • :new - Required. The public key of the newly-created token account

Creates an instruction to mints new tokens to an account.

The native mint does not support minting.

If you want to check the token's mint and decimals, set the checked? option to true and provide the decimals option.

Options

  • :token - Required. The token account which will receive the minted tokens

  • :mint - Required. The mint account which will mint the tokens

  • :authority - Required. the current mint authority

  • :amount - Required. amount of tokens to mint

  • :multi_signers - signing accounts if the authority is a Solana.SPL.Token.MultiSig account

  • :checked? - whether or not to check the token mint and decimals; may be useful when creating transactions offline or within a hardware wallet. The default value is false.

  • :decimals - The number of decimals in the amount. Only used if checked? is true.

Creates an instruction to revoke a previously approved delegate's authority to make transfers.

Options

  • :source - Required. The account to send tokens from

  • :owner - Required. The account which owns source

  • :multi_signers - signing accounts if the owner is a Solana.SPL.Token.MultiSig account

Creates an instruction to set a new authority for a mint or account.

Options

  • :account - Required. The account which will change authority, either a mint or token account

  • :authority - Required. the current authority for mint_or_token

  • :new_authority - the new authority for mint_or_token

  • :type - Required. type of authority to set

  • :multi_signers - signing accounts if the authority is a Solana.SPL.Token.MultiSig account

Creates an instruction to thaw a frozen account using the mint's freeze_authority (if set).

Options

  • :to_thaw - Required. The account to thaw

  • :mint - Required. The mint account for to_thaw

  • :authority - Required. the freeze authority for mint

  • :multi_signers - signing accounts if the authority is a Solana.SPL.Token.MultiSig account

Creates an instruction to transfer 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.

If you want to check the token's mint and decimals, set the checked? option to true and provide the mint and decimals options.

Options

  • :from - Required. The account to send tokens from

  • :to - Required. The account to receive tokens

  • :owner - Required. The owner of from

  • :multi_signers - signing accounts if the owner is a Solana.SPL.Token.MultiSig account

  • :amount - Required. The number of tokens to send

  • :checked? - whether or not to check the token mint and decimals; may be useful when creating transactions offline or within a hardware wallet. The default value is false.

  • :decimals - The number of decimals in the amount. Only used if checked? is true.

  • :mint - The mint account for from and to. Only used if checked? is true.