Instruction builders for the SPL Token Program.
Works with both SPL Token and Token-2022 via the :token_program option.
SPL Token uses a 1-byte instruction index (unlike System Program's 4-byte u32).
Examples
iex> ix = Cartouche.Solana.TokenProgram.transfer(<<1::256>>, <<2::256>>, <<3::256>>, 1_000_000)
iex> ix.data
<<3, 64, 66, 15, 0, 0, 0, 0, 0>>
Summary
Functions
Approve a delegate to transfer up to amount tokens from source.
Close a token account, transferring remaining SOL rent to destination.
Sync the native SOL balance of a wrapped SOL token account.
Transfer tokens from source to destination.
Transfer tokens with decimal verification (preferred over transfer/5).
Functions
@spec approve(<<_::256>>, <<_::256>>, <<_::256>>, non_neg_integer(), keyword()) :: Cartouche.Solana.Transaction.Instruction.t()
Approve a delegate to transfer up to amount tokens from source.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec close_account(<<_::256>>, <<_::256>>, <<_::256>>, keyword()) :: Cartouche.Solana.Transaction.Instruction.t()
Close a token account, transferring remaining SOL rent to destination.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec sync_native( <<_::256>>, keyword() ) :: Cartouche.Solana.Transaction.Instruction.t()
Sync the native SOL balance of a wrapped SOL token account.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec transfer(<<_::256>>, <<_::256>>, <<_::256>>, non_neg_integer(), keyword()) :: Cartouche.Solana.Transaction.Instruction.t()
Transfer tokens from source to destination.
The authority must sign the transaction.
Options
:token_program- Override the token program (default: SPL Token Program).
@spec transfer_checked( <<_::256>>, <<_::256>>, <<_::256>>, <<_::256>>, non_neg_integer(), non_neg_integer(), keyword() ) :: Cartouche.Solana.Transaction.Instruction.t()
Transfer tokens with decimal verification (preferred over transfer/5).
Requires passing the mint, preventing accidental wrong-decimal transfers.
Options
:token_program- Override the token program (default: SPL Token Program).