Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class TokenProgram
- Object
- TokenProgram
Instructions of the SPL Token program and the Associated Token Account program. Token
amounts are raw base units, unsigned 64-bit; a mint’s
decimals says where the point is.
Each builder has a form that takes the token program, for mints under Token-2022.Methods
Inherited methods
Method details
transfer
public static Instruction transfer(SolanaAddress source, SolanaAddress destination, SolanaAddress owner, long amount)Transfer: moves tokens between two token accounts; owner signs.transferChecked
public static Instruction transferChecked(SolanaAddress source, SolanaAddress mint, SolanaAddress destination, SolanaAddress owner, long amount, int decimals)TransferChecked: a transfer that also names the mint and its decimals, which wallets
prefer and Token-2022 requires.transferChecked
public static Instruction transferChecked(SolanaAddress tokenProgram, SolanaAddress source, SolanaAddress mint, SolanaAddress destination, SolanaAddress owner, long amount, int decimals)TransferChecked under a given token program.closeAccount
public static Instruction closeAccount(SolanaAddress account, SolanaAddress destination, SolanaAddress owner)CloseAccount: closes an empty token account and returns its rent to destination.createAssociatedTokenAccount
public static Instruction createAssociatedTokenAccount(SolanaAddress payer, SolanaAddress wallet, SolanaAddress mint, boolean idempotent)Creates the associated token account of
wallet for mint, paid by payer. The
idempotent form succeeds when the account already exists, which is what a sender
wants before a first transfer to a recipient.createAssociatedTokenAccount
public static Instruction createAssociatedTokenAccount(SolanaAddress payer, SolanaAddress wallet, SolanaAddress mint, SolanaAddress tokenProgram, boolean idempotent)Creates an associated token account under a given token program.