TokenInstruction class
A spl token program instruction.
- Inheritance
-
- Object
- Instruction
- TokenInstruction
Constructors
-
TokenInstruction.approve({required int amount, required Ed25519HDPublicKey source, required Ed25519HDPublicKey delegate, required Ed25519HDPublicKey sourceOwner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[]}) -
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>[]}) -
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>[]}) -
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>[]}) -
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>[]}) -
Close an account by transferring all its SOL to the destination account.
factory
-
TokenInstruction.freezeAccount({required Ed25519HDPublicKey account, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey freezeAuthority, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[]}) -
Freeze an Initialized
account
using the mint'sfreezeAuthority
.factory - TokenInstruction.initializeAccount({required Ed25519HDPublicKey account, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner})
-
Initializes a new
account
to hold tokens.factory - TokenInstruction.initializeAccount2({required Ed25519HDPublicKey pubKey, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey owner})
-
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})
-
Like TokenInstruction.initializeAccount2, but does not require the Rent
sysvar to be provided.
factory
- TokenInstruction.initializeMint({required int decimals, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey mintAuthority, Ed25519HDPublicKey? freezeAuthority})
-
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})
-
Like TokenInstruction.initializeMint, but does not require the Rent
sysvar to be provided.
factory
-
TokenInstruction.initializeMultisig({required Ed25519HDPublicKey account, required List<
Ed25519HDPublicKey> signers}) -
Initializes a multisignature
account
with N providedsigners
.factory -
TokenInstruction.initializeMultisig2({required Ed25519HDPublicKey pubKey, required List<
Ed25519HDPublicKey> signerPubKeys}) -
Like TokenInstruction.initializeMultisig, but does not require the Rent
sysvar to be provided.
factory
- TokenInstruction.mintTo({required int amount, required Ed25519HDPublicKey mint, required Ed25519HDPublicKey destination, required Ed25519HDPublicKey authority})
-
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})
-
Mints new tokens to an account. The native mint does not support minting.
factory
-
TokenInstruction.revoke({required Ed25519HDPublicKey source, required Ed25519HDPublicKey sourceOwner, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[]}) -
Revokes the delegate's authority.
factory
-
TokenInstruction.setAuthority({required Ed25519HDPublicKey mintOrAccount, required Ed25519HDPublicKey currentAuthority, required AuthorityType authorityType, Ed25519HDPublicKey? newAuthority, List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[]}) -
Sets a new authority of a mint or account.
factory
- TokenInstruction.syncNative({required Ed25519HDPublicKey nativeTokenAccount})
-
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>[]}) -
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>[]}) -
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>[]}) -
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
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 ==(
dynamic 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}) → 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}) → List< Instruction> -
Create an account with
address
and owned byowner
. Therent