Expand description
Hopper-owned SPL Token builder surface.
Thin first-class Hopper wrappers over the canonical runtime builders. This crate gives Hopper a native token CPI surface instead of forcing authored programs to depend on external helper crates.
Modules§
- instructions
- SPL Token instruction builders exported by Hopper.
- layout
- Kani proofs and golden-vector tests for the shipped SPL Token and System-program CPI instruction-data encoders.
Structs§
- Amount
ToUi Amount AmountToUiAmount(23): format a raw amount with the mint’s decimals (and, on Token-2022, its interest or scaled-UI configuration) as a UTF-8 string in the return data. Read it withreturn_data_string.- Approve
Checked - Builder for SPL Token ApproveChecked (instruction index 13).
- Burn
Checked - Builder for SPL Token BurnChecked (instruction index 15).
- Checked
Mint Decimals - Proof token that an SPL Mint matched expected decimals.
- Checked
Token Authority - Proof token that an SPL TokenAccount matched an expected token authority.
- Checked
Token Mint - Proof token that an SPL TokenAccount matched an expected mint.
- Close
Account - Builder for SPL Token CloseAccount (instruction index 9).
- Freeze
Account - Builder for SPL Token FreezeAccount (instruction index 10).
- GetAccount
Data Size GetAccountDataSize(21): ask the token program how many bytes a token account formintneeds, as au64in the return data. On Token-2022 the mint’s required account extensions are included automatically andextension_typesadds more (for examplecrate::token_2022_ext::EXT_IMMUTABLE_OWNER); SPL Token ignores the list and answers 165.- Initialize
Account - Builder for SPL Token InitializeAccount (instruction index 1).
- Initialize
Account2 - Builder for SPL Token InitializeAccount2 (instruction index 16).
- Initialize
Account3 - Builder for SPL Token InitializeAccount3 (instruction index 18).
- Initialize
Immutable Owner InitializeImmutableOwner(22): mark a not-yet-initialized token account so that its owner can never be changed. Runs beforeInitializeAccount3. On Token-2022 it needs the 4-byte extension header in the allocation (GetAccountDataSizewith type 7 reports the size); SPL Token accepts it as a no-op on a 165-byte account.- Initialize
Mint InitializeMint(0): the Rent-sysvar form ofInitializeMint2. The mint must already be allocated (82 bytes on SPL Token) and owned by the token program. PreferInitializeMint2in new code; this form exists for callers whose instruction already carries the Rent sysvar.- Initialize
Mint2 - Low-level
InitializeMint2CPI builder for either token program. - Initialize
Multisig InitializeMultisig(2): turn a 355-byte, token-program-owned account into anm-of-nmultisig oversigners. The member accounts are listed read-only and do not sign. Requires the Rent sysvar account;InitializeMultisig2does not.- Initialize
Multisig2 InitializeMultisig2(19):InitializeMultisigwithout the Rent sysvar account.- Mint
Config - Base mint configuration. Initializing a mint does not mint any supply.
- Mint
Plan - Validated, allocation-free mint creation plan.
- Mint
ToChecked - Builder for SPL Token MintToChecked (instruction index 14).
- Revoke
- Builder for SPL Token Revoke (instruction index 5).
- SetAuthority
- Builder for SPL Token SetAuthority (instruction index 6).
- SplMint
- Known external SPL Mint adapter.
- SplMint
View - Guard-owned zero-copy SPL Mint view.
- SplToken
Account - Known external SPL TokenAccount adapter.
- SplToken
Account View - Guard-owned zero-copy SPL TokenAccount view.
- Sync
Native - Builder for SPL Token SyncNative (instruction index 17).
- Thaw
Account - Builder for SPL Token ThawAccount (instruction index 11).
- Token
Amount Snapshot - Snapshot of a token account amount before CPI.
- Token
Batch - A stack-resident batch of token instructions.
- Trailing
- A run of accounts appended after a builder’s fixed accounts, all with the same privileges: the multisig signers of an authority, the member list of a new multisig, or the source accounts of a withheld-fee sweep.
- Transfer
Checked - Builder for classic SPL Token TransferChecked (instruction index 12).
- UiAmount
ToAmount UiAmountToAmount(24): parse a decimal string against the mint and return the raw amount as au64in the return data. Read it withreturn_data_u64. Strings longer thanMAX_UI_AMOUNT_LENbytes are refused before the CPI.- Unwrap
Lamports UnwrapLamports(45): move lamports out of a native (wrapped SOL) token account todestinationwithout closing it, the whole balance withamount: Noneor a part of it. The instruction exists in the p-token build of SPL Token; a program that does not know discriminator 45 refuses it withInvalidInstructionData.- Withdraw
Excess Lamports WithdrawExcessLamports(38): move every lamport above the rent-exempt minimum out of a token account, mint, or multisig intodestination.authorityis the account’s owner (or the mint’s close authority, or the multisig itself), directly signed or through multisig signers.
Enums§
- Token
Authority Type - Authority classes accepted by SPL Token’s SetAuthority instruction.
- Token
Program - The two token programs every builder in this module can target.
Constants§
- BATCH_
DISCRIMINATOR - The
Batchdiscriminator. - BATCH_
INSTRUCTION_ HEADER_ LEN - Bytes of header in front of each inner instruction: its account count and its data length, one byte each.
- MAX_
TOKEN_ MULTISIG_ SIGNERS - SPL Token multisig accounts support at most 11 signer accounts.
- MAX_
UI_ AMOUNT_ LEN - The longest UI-amount string
UiAmountToAmountcarries: the instruction is one byte of discriminator plus at most 254 bytes of UTF-8. - TOKEN_
2022_ PROGRAM_ ID - Token-2022 program address.
- TOKEN_
PROGRAM_ ID - SPL Token program address.
Traits§
- Token
Instruction - An SPL Token / Token-2022 instruction builder: something that can encode
itself into a
TokenSink. - Token
Sink - Where a builder’s encoded instruction goes.
Functions§
- return_
data_ string - The string a token program left in the return data, copied into
out; the result is its length. Refuses return data from any other program and anything longer than the buffer. - return_
data_ u64 - The
u64a token program left in the return data, refusing return data set by any other program or shorter than eight bytes.
Type Aliases§
- Mint
Program - The token program a mint is created on: the same selector every token builder takes, under the name mint creation has always used.