solana-token-toolkit
Token account workflow primitives for Solana applications.
Status: v0.1 (initial release). API is stable within minor versions.
What this is
solana-token-toolkit provides three tiers of token-account utilities:
- State (
fetch_token_account_state,assemble_token_account_state) — query the on-chain state of an owner's ATAs across a set of mints - Mint extensions (
get_token_mint_and_transfer_fee,detect_transfer_hooks,reject_transfer_hook_mints) — parse Token-2022 transfer fees (epoch-aware) and detect / reject transfer hooks - ATA workflow (
prepare_token_accounts) — produce instructions to prepare token accounts for a transaction, including the full ephemeral-keypair wSOL wrapping path
It is independent of any DEX or wallet abstractions. No global mutable state. No anyhow in public API.
Installation
[]
= "0.1"
= "3"
= "3"
= "4"
= "3"
= "2" # for native_mint::ID in examples
Compatible with stable Solana SDK 3.x split crates. MSRV: Rust 1.89.
Stability policy for v0.1: this crate intentionally uses stable
solana-client = 3and avoids Solana client 4 beta releases.solana-accountremains on the Solana 3.x line because stablesolana-clientreturns that account type. Solana 4 support should be a future minor release once the client stack is stable.
Usage
use HashMap;
use RpcClient;
use Keypair;
use Pubkey;
use Signer;
use *;
use native_mint;
# async
Key design decisions
- No global mutable state —
WrapSolStrategyis per-call. - Caller-provided rent — the library stays synchronous in Tier 3.
- Deterministic instruction order —
prepare_token_accountssorts intents by mint pubkey. - Typed errors — no
anyhowin public API. - No Seed strategy — protocol-specific wrapping is intentionally out of scope.
- Temporary wSOL when created by the toolkit —
MintIntent::WithBalance+WrapSolStrategy::Atacreates a wSOL ATA if missing, uses it for the main transaction, and includes a cleanup close instruction for that newly-created ATA. Existing user wSOL ATAs are never auto-closed.
License
Dual-licensed under MIT or Apache-2.0.