SPLTokenProgram class
This class represents instructions for interacting with the SPL Token Program
- Inheritance
-
- Object
- TransactionInstruction
- SPLTokenProgram
Constructors
-
SPLTokenProgram({required List<
AccountMeta> keys, required SolAddress programId, required ProgramLayout layout}) - SPLTokenProgram.amountToUiAmount({required SPLTokenAmountToUiAmountLayout layout, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Convert an Amount of tokens to a UiAmount
string
, using the given mint. In this version of the program, the mint can only specify the number of decimals.factory -
SPLTokenProgram.approve({required SPLTokenApproveLayout layout, required SolAddress account, required SolAddress delegate, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Approves a delegate. A delegate is given the authority over tokens on
behalf of the source account's owner.
factory
-
SPLTokenProgram.approveChecked({required SPLTokenApproveCheckedLayout layout, required SolAddress account, required SolAddress mint, required SolAddress delegate, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Approves a delegate. A delegate is given the authority over tokens on
behalf of the source account's owner.
factory
-
SPLTokenProgram.burn({required SPLTokenBurnLayout layout, required SolAddress account, required SolAddress mint, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Burns tokens by removing them from an account. SPLTokenProgram.burn does not support
accounts associated with the native mint, use SPLTokenProgram.closeAccount instead.
factory
-
SPLTokenProgram.burnChecked({required SPLTokenBurnCheckedLayout layout, required SolAddress account, required SolAddress mint, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Burns tokens by removing them from an account. SPLTokenProgram.burnChecked does not
support accounts associated with the native mint, use SPLTokenProgram.closeAccount
instead.
factory
-
SPLTokenProgram.closeAccount({required SolAddress account, required SolAddress destination, required SolAddress authority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Close an account by transferring all its SOL to the destination account.
Non-native accounts may only be closed if its token amount is zero.
factory
- SPLTokenProgram.createNativeMint({required SolAddress payer, SolAddress nativeMintId = SPLTokenProgramConst.nativeMint2022, SolAddress programId = SPLTokenProgramConst.token2022ProgramId})
-
Creates the native mint.
factory
-
SPLTokenProgram.freezeAccount({required SolAddress account, required SolAddress mint, required SolAddress authority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Freeze an Initialized account.
factory
-
SPLTokenProgram.fromBytes({required List<
AccountMeta> keys, required List<int> instructionBytes, SolAddress programId = SPLTokenProgramConst.tokenProgramId}) -
factory
- SPLTokenProgram.initializeAccount({required SolAddress account, required SolAddress mint, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Initializes 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.
factory
- SPLTokenProgram.initializeAccount2({required SPLTokenInitializeAccount2Layout layout, required SolAddress account, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Like 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
- SPLTokenProgram.initializeAccount3({required SPLTokenInitializeAccount3Layout layout, required SolAddress account, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Like InitializeAccount2, but does not require the Rent sysvar to be
provided
factory
- SPLTokenProgram.initializeImmutableOwner({required SolAddress account, required SolAddress programId})
-
Initialize the Immutable Owner extension for the given token account
factory
- SPLTokenProgram.initializeMint({required SPLTokenInitializeMintLayout layout, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Initializes a new mint and optionally deposits all the newly minted
tokens in an account.
factory
- SPLTokenProgram.initializeMint2({required SPLTokenInitializeMint2Layout layout, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Like SPLTokenProgram.initializeMint, but does not require the Rent sysvar to be
provided
factory
- SPLTokenProgram.initializeMintCloseAuthority({required SPLTokenInitializeMintCloseAuthorityLayout layout, required SolAddress mint, required SolAddress programId})
-
Initialize the close account authority on a new mint.
factory
-
SPLTokenProgram.initializeMultisig({required SPLTokenInitializeMultisigLayout layout, required SolAddress account, required List<
SolAddress> signers, SolAddress programId = SPLTokenProgramConst.tokenProgramId}) -
Initializes a multisignature account with N provided signers.
factory
- SPLTokenProgram.initializeNonTransferableMint({required SolAddress mint, required SolAddress programId})
-
Initialize the non transferable extension for the given mint account
factory
- SPLTokenProgram.initializePermanentDelegate({required SPLTokenInitializePermanentDelegateLayout layout, required SolAddress mint, required SolAddress programId})
-
Initialize the permanent delegate on a new mint.
factory
-
SPLTokenProgram.mintTo({required SPLTokenMintToLayout layout, required SolAddress mint, required SolAddress destination, required SolAddress authority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Mints new tokens to an account. The native mint does not support
minting.
factory
-
SPLTokenProgram.mintToChecked({required SPLTokenMintToCheckedLayout layout, required SolAddress mint, required SolAddress destination, required SolAddress authority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Mints new tokens to an account. The native mint does not support
minting.
factory
-
SPLTokenProgram.reallocate({required SPLTokenReallocateLayout layout, required SolAddress account, required SolAddress payer, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.token2022ProgramId, List<
SolAddress> multiSigners = const []}) -
Check to see if a token account is large enough for a list of
ExtensionTypes, and if not, use reallocation to increase the data
size.
factory
-
SPLTokenProgram.revoke({required SolAddress account, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Revokes the delegate's authority.
factory
-
SPLTokenProgram.setAuthority({required SPLTokenSetAuthorityLayout layout, required SolAddress account, required SolAddress currentAuthority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Sets a new authority of a mint or account.
factory
- SPLTokenProgram.syncNative({required SolAddress account, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Given a wrapped / native token account (a token account containing SOL)
updates its amount field based on the account's underlying
lamports
.factory -
SPLTokenProgram.thawAccount({required SolAddress account, required SolAddress mint, required SolAddress authority, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
Thaw a Frozen account.
factory
-
SPLTokenProgram.transfer({required SPLTokenTransferLayout layout, required SolAddress source, required SolAddress destination, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
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
-
SPLTokenProgram.transferChecked({required SPLTokenTransferCheckedLayout layout, required SolAddress source, required SolAddress mint, required SolAddress destination, required SolAddress owner, SolAddress programId = SPLTokenProgramConst.tokenProgramId, List<
SolAddress> multiSigners = const []}) -
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
- SPLTokenProgram.uiAmountToAmount({required SPLTokenUiAmountToAmountLayout layout, required SolAddress mint, SolAddress programId = SPLTokenProgramConst.tokenProgramId})
-
Convert a UiAmount of tokens to a little-endian
u64
raw Amount, using the given mint. In this version of the program, the mint can only specify the number of decimals.factory
Properties
-
data
→ List<
int> -
Program input.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
keys
→ List<
AccountMeta> -
Public keys to include in this transaction
Boolean represents whether this pubkey needs to sign the transaction
finalinherited
- layout → ProgramLayout
-
Program layout.
finalinherited
- programId → SolAddress
-
Program Id to execute.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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