Expand description
High-level builders for Light Token operations.
§Account Creation
CreateAssociatedTokenAccount- Create associated Light Token account (ATA) instructionCreateTokenAtaCpi- Create associated Light Token account (ATA) via CPICreateTokenAccount- Create Light Token account instructionCreateTokenAccountCpi- Create Light Token account via CPI
§Transfers
TransferInterfaceCpi- Transfer via CPI, auto-detect source/destination account types
§Decompress
Decompress- Decompress compressed tokens to a Light Token account
§Close
CloseAccount- Create close Light Token account instructionCloseAccountCpi- Close Light Token account via CPI
§Mint
CreateMint- Create Light Mintcreate_mints- Create multiple Light Mints in a batchMintTo- Mint tokens to Light Token accounts
§Revoke and Thaw
Revoke- Revoke delegation for a Light Token accountRevokeCpi- Revoke delegation via CPIThaw- Thaw a frozen Light Token accountThawCpi- Thaw a frozen Light Token account via CPI
§Example: Create Light Token Account Instruction
use light_token::instruction::CreateAssociatedTokenAccount;
let instruction = CreateAssociatedTokenAccount::new(payer, owner, mint)
.idempotent()
.instruction()?;§Example: Create rent-free ATA via CPI
ⓘ
use light_token::instruction::CreateTokenAtaCpi;
CreateTokenAtaCpi {
payer: ctx.accounts.payer.to_account_info(),
owner: ctx.accounts.owner.to_account_info(),
mint: ctx.accounts.mint.to_account_info(),
ata: ctx.accounts.user_ata.to_account_info(),
bump,
}
.idempotent()
.rent_free(
ctx.accounts.light_token_config.to_account_info(),
ctx.accounts.rent_sponsor.to_account_info(),
ctx.accounts.system_program.to_account_info(),
)
.invoke()?;§Example: Create rent-free vault via CPI (with PDA signing)
ⓘ
use light_token::instruction::CreateTokenAccountCpi;
CreateTokenAccountCpi {
payer: ctx.accounts.payer.to_account_info(),
account: ctx.accounts.vault.to_account_info(),
mint: ctx.accounts.mint.to_account_info(),
owner: ctx.accounts.vault_authority.key(),
}
.rent_free(
ctx.accounts.light_token_config.to_account_info(),
ctx.accounts.rent_sponsor.to_account_info(),
ctx.accounts.system_program.to_account_info(),
&crate::ID,
)
.invoke_signed(&[b"vault", mint.key().as_ref(), &[bump]])?;Structs§
- Additional
Metadata - Approve
- Approve a delegate for a Light Token account:
- Approve
Checked - Approve a delegate for a Light Token account with decimals validation:
- Approve
Checked Cpi - Approve Light Token via CPI with decimals validation:
- Approve
Cpi - Approve Light Token via CPI:
- Burn
- Burn tokens from a ctoken account:
- Burn
Checked - Burn tokens from a ctoken account with decimals validation:
- Burn
Checked Cpi - Burn ctoken via CPI with decimals validation:
- BurnCpi
- Burn ctoken via CPI:
- Close
Account - Create a close ctoken account instruction:
- Close
Account Cpi - Close a ctoken account via CPI:
- Compress
ToPubkey - Compressible
Params - Parameters for creating compressible ctoken accounts.
- Compressible
Params Cpi - Parameters for creating compressible ctoken accounts via CPI.
- Create
Associated Account Cpi - CPI builder for creating CToken ATAs.
- Create
Associated Token Account - Create an associated ctoken account instruction:
- Create
Mint - Create a mint instruction that creates both a compressed mint AND a Mint Solana account.
- Create
Mint Cpi - Create a mint via CPI:
- Create
Mint Params - Parameters for creating a mint.
- Create
Mints Cpi - CPI struct for on-chain programs to create multiple mints.
- Create
Mints Params - Parameters for creating one or more compressed mints with decompression.
- Create
Token Account - Create a create ctoken account instruction:
- Create
Token Account Cpi - CPI builder for creating CToken accounts (vaults).
- Create
Token Account Rent Free Cpi - Rent-free enabled CToken account creation CPI.
- Create
Token AtaCpi - CPI builder for creating CToken ATAs.
- Decompress
- Decompress compressed tokens to a cToken account
- DecompressC
Mint CpiWith Context - CPI struct for decompressing a mint with CPI context.
- DecompressC
Mint With CpiContext - Decompress a compressed mint with CPI context support.
- Decompress
Mint - Decompress a compressed mint to a Mint Solana account.
- Decompress
Mint Cpi - Decompress a compressed mint to a Mint Solana account via CPI.
- Freeze
- Freeze a Light Token account:
- Freeze
Cpi - Freeze Light Token via CPI:
- MintTo
- Mint tokens to a ctoken account (simple 3-account instruction):
- Mint
ToChecked - Mint tokens to a ctoken account with decimals validation:
- Mint
ToChecked Cpi - Mint to ctoken via CPI with decimals validation:
- Mint
ToCpi - Mint to ctoken via CPI:
- Mint
With Context - Revoke
- Revoke delegation for a Light Token account:
- Revoke
Cpi - Revoke Light Token via CPI:
- Single
Mint Params - Parameters for a single mint within a batch creation.
- SplInterface
- Required accounts to interface between light and SPL token accounts (Pubkey-based).
- SplInterface
Cpi - Required accounts to interface between light and SPL token accounts (AccountInfo-based).
- System
Account Infos - System accounts required for CPI operations to Light Protocol.
- System
Accounts - System accounts with Pubkey references for instruction building.
- Thaw
- Thaw a frozen Light Token account:
- ThawCpi
- Thaw Light Token via CPI:
- Token
- Ctoken account structure (same as SPL Token Account but with extensions). Ctokens are solana accounts, compressed tokens are stored as TokenData that is optimized for compressed accounts.
- Token
Metadata Instruction Data - Transfer
- Create a transfer ctoken instruction:
- Transfer
Checked - Create a transfer ctoken checked instruction:
- Transfer
Checked Cpi - Transfer ctoken checked via CPI:
- Transfer
Cpi - Transfer ctoken via CPI:
- Transfer
From Spl - Create a transfer SPL to cToken instruction
- Transfer
From SplCpi - Transfer SPL to ctoken via CPI:
- Transfer
Interface - Create a transfer interface instruction that auto-routes based on account types:
- Transfer
Interface Cpi - Transfer interface via CPI (auto-detects account types):
- Transfer
ToSpl - Create a transfer ctoken to SPL instruction:
- Transfer
ToSpl Cpi - Transfer ctoken to SPL via CPI:
Enums§
- Extension
Instruction Data - Token
Data Version - TokenDataVersion is recorded in the token account discriminator.
Constants§
- COMPRESSIBLE_
CONFIG_ V1 - DEFAULT_
RENT_ PAYMENT - Default rent payment epochs (~24 hours)
- DEFAULT_
WRITE_ TOP_ UP - Default lamports for write operations (~3 hours per write)
- LIGHT_
TOKEN_ CPI_ AUTHORITY - LIGHT_
TOKEN_ PROGRAM_ ID - Compressed Token Program ID:
cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m - RENT_
SPONSOR
Functions§
- compression_
authority_ pda - config_
pda - Returns the default compressible config PDA.
- cpi_
authority - Return the cpi authority pda of the Compressed Token Program.
- create_
decompress_ mint_ cpi_ context_ execute - Helper to create CPI context for execution (both false - consumes context)
- create_
decompress_ mint_ cpi_ context_ first - Helper to create CPI context for first write (first_set_context = true)
- create_
decompress_ mint_ cpi_ context_ set - Helper to create CPI context for subsequent writes (set_context = true)
- create_
mints - Create multiple mints and decompress all to Solana accounts.
- derive_
associated_ token_ account - derive_
mint_ compressed_ address - Derives the compressed mint address from the mint seed and address tree
- derive_
mint_ from_ spl_ mint - Derives the compressed mint address from an SPL mint address
- derive_
token_ ata - find_
mint_ address - Finds the compressed mint address from a mint seed.
- get_
associated_ token_ address - Returns the associated token address for a given owner and mint.
- get_
associated_ token_ address_ and_ bump - Returns the associated token address and bump for a given owner and mint.
- get_
spl_ interface_ pda_ and_ bump - id
- Returns the program ID for the Compressed Token Program
- rent_
sponsor_ pda - Returns the default rent sponsor PDA.