Skip to main content

  1. Freeze prevents all transfers or token burns from a specific light-token account.
  2. Once frozen, the account cannot send tokens, receive tokens, or be closed until it is thawed.
  3. Thaw re-enables transfers on a frozen light-token account.
  4. Only the freeze authority (set at mint creation) can freeze or thaw accounts.
  5. If the freeze authority is revoked (set to null) on the mint account, tokens can never be frozen.
1

Prerequisites

Cargo.toml
[dependencies]
light-compressed-token-sdk = "0.1"
light-client = "0.1"
light-token-types = "0.1"
solana-sdk = "2.2"
borsh = "0.10"
tokio = { version = "1.36", features = ["full"] }

[dev-dependencies]
light-program-test = "0.1"  # For in-memory tests with LiteSVM
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

Freeze or thaw light-token accounts

View Source Code or find full examples with tests: examples-light-token.
mod shared;

use light_client::rpc::Rpc;
use light_token_sdk::token::Freeze;
use shared::SetupContext;
use solana_sdk::signer::Signer;

#[tokio::test(flavor = "multi_thread")]
async fn test_freeze() {
    // Setup creates mint, ATA with tokens, and approves delegate
    let SetupContext {
        mut rpc,
        payer,
        mint,
        ata,
        ..
    } = shared::setup().await;

    let freeze_ix = Freeze {
        token_account: ata,
        mint,
        freeze_authority: payer.pubkey(),
    }
    .instruction()
    .unwrap();

    rpc.create_and_send_transaction(&[freeze_ix], &payer.pubkey(), &[&payer])
        .await
        .unwrap();
}

Next Steps

Approve and Revoke Delegates for Light Token Accounts