Documentation Index
Fetch the complete documentation index at: https://mintlify.com/blueshift-gg/quasar/llms.txt
Use this file to discover all available pages before exploring further.
quasar-spl is the SPL Token companion crate for Quasar programs. It ships zero-copy account wrappers for Mint and Token accounts, a unified TokenCpi trait that works with both SPL Token and Token-2022, and a declarative #[account(init)] system that generates the correct CPI calls to create mints, token accounts, and associated token accounts without any heap allocation.
Adding quasar-spl
Add the crate to your program’sCargo.toml:
What the Prelude Exports
use quasar_spl::prelude::* re-exports everything you need for day-to-day token programming:
| Export | Description |
|---|---|
Mint | Zero-copy SPL Token mint wrapper (Account<Mint> / InterfaceAccount<Mint>) |
Token | Zero-copy SPL Token account wrapper (Account<Token> / InterfaceAccount<Token>) |
Mint2022 | Zero-copy Token-2022 mint wrapper (Account<Mint2022>) |
Token2022 | Zero-copy Token-2022 account wrapper (Account<Token2022>) |
TokenProgram | Program marker for SPL Token (Program<TokenProgram>) |
Token2022Program | Program marker for Token-2022 (Program<Token2022Program>) |
TokenInterface | Interface marker accepting either program (Interface<TokenInterface>) |
AssociatedTokenProgram | Program marker for the ATA program |
TokenCpi | Trait providing .transfer(), .mint_to(), .burn(), etc. |
accounts::{ associated_token, mint, token, token_close, token_sweep } | Behavior modules for #[account(...)] annotations |
spl/src/prelude.rs and re-exports from the crate root:
Account Type Matrix
Quasar-spl provides four concrete account types and one interface type. Choose the right one based on whether you need to support one or both token programs:| Wrapper | Owner check | Underlying data | Use when |
|---|---|---|---|
Account<Token> | SPL Token only | TokenDataZc (165 bytes) | Token accounts for SPL Token |
Account<Mint> | SPL Token only | MintDataZc (82 bytes) | Mints owned by SPL Token |
Account<Token2022> | Token-2022 only | TokenDataZc (165 bytes) | Token accounts for Token-2022 |
Account<Mint2022> | Token-2022 only | MintDataZc (82 bytes) | Mints owned by Token-2022 |
InterfaceAccount<Token> | SPL Token or Token-2022 | TokenDataZc | Accounts accepted by either program |
InterfaceAccount<Mint> | SPL Token or Token-2022 | MintDataZc | Mints from either program |
Deref target (TokenDataZc or MintDataZc). No deserialization occurs — the framework reinterprets account data in place.
Program Markers
Three program account types are provided. Each implements theTokenCpi trait so you can call CPI methods directly on the program field:
Program<TokenProgram> verifies the account is the executable at TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. Program<Token2022Program> verifies TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb. Interface<TokenInterface> accepts either address at runtime and dispatches the correct CPI call to whichever token program was supplied.
The TokenCpi Trait
TokenCpi is a single trait implemented by Program<TokenProgram>, Program<Token2022Program>, and Interface<TokenInterface>. Every method returns a CpiCall that you finalize with .invoke() or .invoke_signed(&seeds):
TokenCpi is: transfer, transfer_checked, mint_to, burn, approve, revoke, close_account, sync_native, initialize_account3, and initialize_mint2.
Built-in Init Support
The#[account(init, ...)] attribute on any Account<Token>, Account<Mint>, or Account<Token2022> field triggers an automatic CPI sequence during account deserialization. No manual system_program.create_account call is needed.
Initialize a mint:
init(idempotent) variant uses CreateIdempotent under the hood so the instruction is safe to re-run if the ATA already exists.
Program Addresses
Three well-known addresses are exported from the crate root:| Constant | Address |
|---|---|
SPL_TOKEN_ID | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA |
TOKEN_2022_ID | TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb |
ATA_PROGRAM_ID | ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL |
SPL Token
Mint and Token zero-copy wrappers,
TokenCpi methods, init patterns, and escrow examples for SPL Token programs.Token-2022
Token-2022 account types,
Interface<TokenInterface> for multi-program support, and migration guidance.