TokenInstruction class
A spl token program instruction.
- Inheritance
-
- Object
- Instruction
- TokenInstruction
Constructors
- TokenInstruction.amountToUiAmount({required Ed25519HDPublicKey mint, required int amount, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Convert an
amount
of tokens to a UiAmountstring
, using the given mint. In this version of the program, themint
can only specify the number of decimals.factory -
TokenInstruction.approve({required int amount, required Ed25519HDPublicKey source, required Ed25519HDPublicKey delegate, required Ed25519HDPublicKey sourceOwner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Approves a
delegate
.factory -
TokenInstruction.approveChecked({required int amount, required int decimals, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey source, required Ed25519HDPublicKey delegate, required Ed25519HDPublicKey sourceOwner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Approves a delegate. A delegate is given the authority over tokens on
behalf of the source account's owner.
factory
-
TokenInstruction.burn({required int amount, required Ed25519HDPublicKey accountToBurnFrom, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Burns tokens by removing them from an account.
factory
-
TokenInstruction.burnChecked({required int amount, required int decimals, required Ed25519HDPublicKey accountToBurnFrom, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Burns tokens by removing them from an account.
factory
-
TokenInstruction.closeAccount({required Ed25519HDPublicKey accountToClose, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey owner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Close an account by transferring all its SOL to the destination account.
factory
- TokenInstruction.createNativeMint({required Ed25519HDPublicKey payer})
-
Creates the native mint.
factory
-
TokenInstruction.freezeAccount({required Ed25519HDPublicKey account, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey freezeAuthority, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Freeze an Initialized
account
using the mint'sfreezeAuthority
.factory - TokenInstruction.getAccountDataSize({required Ed25519HDPublicKey mint, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Gets the required size of an account for the given mint as a
little-endian
u64
.factory - TokenInstruction.initializeAccount({required Ed25519HDPublicKey account, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Initializes a new
account
to hold tokens.factory - TokenInstruction.initializeAccount2({required Ed25519HDPublicKey pubKey, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Like TokenInstruction.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.factory - TokenInstruction.initializeAccount3({required Ed25519HDPublicKey pubKey, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Like TokenInstruction.initializeAccount2, but does not require the Rent
sysvar to be provided.
factory
- TokenInstruction.initializeImmutableOwner({required Ed25519HDPublicKey account, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Initialize the Immutable Owner extension for the given token account
factory
- TokenInstruction.initializeMint({required int decimals, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey mintAuthority, Ed25519HDPublicKey? freezeAuthority, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Construct an instruction to initialize a new spl token with address
mint
,decimals
decimal places, andmintAuthority
as the mint authority.factory - TokenInstruction.initializeMint2({required int decimals, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey mintAuthority, Ed25519HDPublicKey? freezeAuthority, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Like TokenInstruction.initializeMint, but does not require the Rent
sysvar to be provided.
factory
- TokenInstruction.initializeMintCloseAuthority({required Ed25519HDPublicKey mint, required Ed25519HDPublicKey? closeAuthority})
-
Initialize the close account authority on a new mint.
factory
-
TokenInstruction.initializeMultisig({required Ed25519HDPublicKey account, required List<
Ed25519HDPublicKey> signers, TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Initializes a multisignature
account
with N providedsigners
.factory -
TokenInstruction.initializeMultisig2({required Ed25519HDPublicKey pubKey, required List<
Ed25519HDPublicKey> signerPubKeys, TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Like TokenInstruction.initializeMultisig, but does not require the Rent
sysvar to be provided.
factory
- TokenInstruction.initializeNonTransferableMint({required Ed25519HDPublicKey mint})
-
Initialize the non transferable extension for the given
mint
accountfactory - TokenInstruction.initializePermanentDelegate({required Ed25519HDPublicKey mint, required Ed25519HDPublicKey? delegate})
-
Fails if the
mint
has already been initialized, so must be called beforeInitializeMint
.factory - TokenInstruction.mintTo({required int amount, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey authority, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Mint the
destination
account withamount
tokens of themint
token. Theauthority
is the mint authority of the token.factory - TokenInstruction.mintToChecked({required int amount, required int decimals, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey authority, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Mints new tokens to an account. The native mint does not support minting.
factory
-
TokenInstruction.reallocate({required Ed25519HDPublicKey account, required Ed25519HDPublicKey payer, required List<
ExtensionType> extensionTypes, required Ed25519HDPublicKey owner, List<Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[]}) -
Check to see if a token
account
is large enough for a list ofextensionTypes
, and if not, use reallocation to increase the data size.factory -
TokenInstruction.revoke({required Ed25519HDPublicKey source, required Ed25519HDPublicKey sourceOwner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Revokes the delegate's authority.
factory
-
TokenInstruction.setAuthority({required Ed25519HDPublicKey mintOrAccount, required Ed25519HDPublicKey currentAuthority, required AuthorityType authorityType, Ed25519HDPublicKey? newAuthority, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Sets a new authority of a mint or account.
factory
- TokenInstruction.syncNative({required Ed25519HDPublicKey nativeTokenAccount, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Given a wrapped / native token account (a token account containing SOL)
updates its amount field based on the account's underlying
lamports
. This is useful if a non-wrapped SOL account uses SystemInstruction.transfer to move lamports to a wrapped token account, and needs to have its tokenamount
field updated.factory -
TokenInstruction.thawAccount({required Ed25519HDPublicKey account, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey freezeAuthority, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Thaw a Frozen
account
using the mint'sfreezeAuthority
.factory -
TokenInstruction.transfer({required int amount, required Ed25519HDPublicKey source, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey owner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
Transfers tokens from one
source
account todestination
either directly or via a delegate.factory -
TokenInstruction.transferChecked({required int amount, required int decimals, required Ed25519HDPublicKey source, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey owner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[], TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) -
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.
factory
- TokenInstruction.uiAmountToAmount({required Ed25519HDPublicKey mint, required String amount, TokenProgramType tokenProgram = TokenProgramType.tokenProgram})
-
Convert a UiAmount of tokens to a little-endian
u64
rawamount
, using the givenmint
.factory
Properties
-
accounts
→ List<
AccountMeta> -
finalinherited
- data → ByteArray
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- programId → Ed25519HDPublicKey
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
compile(
Map< Ed25519HDPublicKey, int> accountIndexesMap) → CompiledInstruction -
Compiles instruction according to the instruction format.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
createAccountAndInitializeMint(
{required Ed25519HDPublicKey mint, required Ed25519HDPublicKey mintAuthority, required int rent, required int space, required int decimals, Ed25519HDPublicKey? freezeAuthority, TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) → List< Instruction> -
Initialize a new spl token with address
mint
,decimals
decimal places, andmintAuthority
as the mint authority. -
createAndInitializeAccount(
{required Ed25519HDPublicKey mint, required Ed25519HDPublicKey address, required Ed25519HDPublicKey owner, required int rent, required int space, TokenProgramType tokenProgram = TokenProgramType.tokenProgram}) → List< Instruction> -
Create an account with
address
and owned byowner
. Therent