Module instruction

Module instruction 

Source
Expand description

High-level builders for Light Token operations.

§Account Creation

§Transfers

§Decompress

  • Decompress - Decompress compressed tokens to a Light Token account

§Close

§Mint

§Revoke and Thaw

  • Revoke - Revoke delegation for a Light Token account
  • RevokeCpi - Revoke delegation via CPI
  • Thaw - Thaw a frozen Light Token account
  • ThawCpi - 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§

AdditionalMetadata
Approve
Approve a delegate for a Light Token account:
ApproveChecked
Approve a delegate for a Light Token account with decimals validation:
ApproveCheckedCpi
Approve Light Token via CPI with decimals validation:
ApproveCpi
Approve Light Token via CPI:
Burn
Burn tokens from a ctoken account:
BurnChecked
Burn tokens from a ctoken account with decimals validation:
BurnCheckedCpi
Burn ctoken via CPI with decimals validation:
BurnCpi
Burn ctoken via CPI:
CloseAccount
Create a close ctoken account instruction:
CloseAccountCpi
Close a ctoken account via CPI:
CompressToPubkey
CompressibleParams
Parameters for creating compressible ctoken accounts.
CompressibleParamsCpi
Parameters for creating compressible ctoken accounts via CPI.
CreateAssociatedAccountCpi
CPI builder for creating CToken ATAs.
CreateAssociatedTokenAccount
Create an associated ctoken account instruction:
CreateMint
Create a mint instruction that creates both a compressed mint AND a Mint Solana account.
CreateMintCpi
Create a mint via CPI:
CreateMintParams
Parameters for creating a mint.
CreateMintsCpi
CPI struct for on-chain programs to create multiple mints.
CreateMintsParams
Parameters for creating one or more compressed mints with decompression.
CreateTokenAccount
Create a create ctoken account instruction:
CreateTokenAccountCpi
CPI builder for creating CToken accounts (vaults).
CreateTokenAccountRentFreeCpi
Rent-free enabled CToken account creation CPI.
CreateTokenAtaCpi
CPI builder for creating CToken ATAs.
Decompress
Decompress compressed tokens to a cToken account
DecompressCMintCpiWithContext
CPI struct for decompressing a mint with CPI context.
DecompressCMintWithCpiContext
Decompress a compressed mint with CPI context support.
DecompressMint
Decompress a compressed mint to a Mint Solana account.
DecompressMintCpi
Decompress a compressed mint to a Mint Solana account via CPI.
Freeze
Freeze a Light Token account:
FreezeCpi
Freeze Light Token via CPI:
MintTo
Mint tokens to a ctoken account (simple 3-account instruction):
MintToChecked
Mint tokens to a ctoken account with decimals validation:
MintToCheckedCpi
Mint to ctoken via CPI with decimals validation:
MintToCpi
Mint to ctoken via CPI:
MintWithContext
Revoke
Revoke delegation for a Light Token account:
RevokeCpi
Revoke Light Token via CPI:
SingleMintParams
Parameters for a single mint within a batch creation.
SplInterface
Required accounts to interface between light and SPL token accounts (Pubkey-based).
SplInterfaceCpi
Required accounts to interface between light and SPL token accounts (AccountInfo-based).
SystemAccountInfos
System accounts required for CPI operations to Light Protocol.
SystemAccounts
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.
TokenMetadataInstructionData
Transfer
Create a transfer ctoken instruction:
TransferChecked
Create a transfer ctoken checked instruction:
TransferCheckedCpi
Transfer ctoken checked via CPI:
TransferCpi
Transfer ctoken via CPI:
TransferFromSpl
Create a transfer SPL to cToken instruction
TransferFromSplCpi
Transfer SPL to ctoken via CPI:
TransferInterface
Create a transfer interface instruction that auto-routes based on account types:
TransferInterfaceCpi
Transfer interface via CPI (auto-detects account types):
TransferToSpl
Create a transfer ctoken to SPL instruction:
TransferToSplCpi
Transfer ctoken to SPL via CPI:

Enums§

ExtensionInstructionData
TokenDataVersion
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.