Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.zkcompression.com/llms.txt

Use this file to discover all available pages before exploring further.


  1. Light token accounts are Solana accounts that hold token balances of light, SPL, or Token 2022 mints.
  2. Light token accounts are on-chain accounts like SPL ATA’s, but the light token program sponsors the rent-exemption cost for you.
  1. A rent sponsor PDA by Light Protocol pays the rent-exemption cost for the account.
  2. Transaction fee payers bump a virtual rent balance when writing to the account, which keeps the account “hot”.
  3. “Cold” accounts virtual rent balance below threshold (eg 24h without write bump) get auto-compressed.
  4. The cold account’s state is cryptographically preserved on the Solana ledger. Users can load a cold account into hot state in-flight when using the account again.
Install or view dedicated agent skills.
npx skills add Lightprotocol/skills
Install orchestrator agent skill or view skill.md:
npx skills add https://zkcompression.com
CreateTokenAccount creates an on-chain token account to store token balances of light, SPL, or Token 2022 mints.Compare to SPL:
1

Prerequisites

Cargo.toml
[dependencies]
light-token = "0.23.0"
light-client = { version = "0.23.0", features = ["v2"] }
solana-sdk = "2"
borsh = "0.10.4"
tokio = { version = "1", features = ["full"] }
Test with Lite-SVM (…)
# Initialize project
cargo init my-light-project
cd my-light-project

# Run tests
cargo test
use light_program_test::{LightProgramTest, ProgramTestConfig};
use solana_sdk::signer::Signer;

#[tokio::test]
async fn test_example() {
    // In-memory test environment 
    let mut rpc = LightProgramTest::new(ProgramTestConfig::default())
        .await
        .unwrap();

    let payer = rpc.get_payer().insecure_clone();
    println!("Payer: {}", payer.pubkey());
}
2

Create Token Account

Find the source code here.
use light_client::rpc::Rpc;
use light_token::instruction::CreateTokenAccount;
use rust_client::{setup_spl_mint_context, SplMintContext};
use solana_sdk::{signature::Keypair, signer::Signer};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Setup creates mint
    // You can use Light, SPL, or Token-2022 mints to create a light token account.
    let SplMintContext {
        mut rpc,
        payer,
        mint,
    } = setup_spl_mint_context().await;

    let account = Keypair::new();

    let create_token_account_instruction =
        CreateTokenAccount::new(payer.pubkey(), account.pubkey(), mint, payer.pubkey())
            .instruction()?;

    let sig = rpc
        .create_and_send_transaction(&[create_token_account_instruction], &payer.pubkey(), &[&payer, &account])
        .await?;

    let data = rpc.get_account(account.pubkey()).await?;
    println!(
        "Account: {} exists: {} Tx: {sig}",
        account.pubkey(),
        data.is_some()
    );

    Ok(())
}

Transfer interface

Wrap and unwrap


Didn’t find what you were looking for?

Reach out! Telegram | email | Discord