Skip to main content

Module token

Module token 

Source
Expand description

The SPL token-account layout shared by Token and Token-2022: build one, read its balance and mint, or re-balance an existing one.

Enums§

TokenAccountError
Why with_token_amount could not re-balance an account.
TokenProgram
The program that owns a token account, and so defines its layout.

Constants§

TOKEN_2022_PROGRAM_ID
The Token-2022 program.
TOKEN_ACCOUNT_LEN
Base SPL token-account length; Token-2022 extensions follow it.
TOKEN_ACCOUNT_RENT_EXEMPT_LAMPORTS
Rent-exempt minimum for a base-length token account.

Functions§

token_account
An initialized 165-byte account holding amount of mint. Wrapped SOL under Token gets is_native = Some(rent) and rent + amount lamports, otherwise SyncNative/transfers revert. Token-2022 mints whose transfers need account extensions (fee, hook, pausable) need the real account re-balanced with with_token_amount instead.
token_amount
amount of an initialized token account; None for a mint, a closed account or short data.
token_mint
mint of an initialized token account; None for a mint, a closed account or short data.
with_token_amount
account with its balance set to amount and every other byte kept. A native account’s lamports become its stored reserve plus amount.