Skip to main content

  1. loadAta unifies tokens from multiple sources to a single ATA:
    • Compressed tokens (cold) -> Decompresses -> light ATA
    • SPL balance (if wrap=true) -> Wraps -> light ATA
    • T22 balance (if wrap=true) -> Wraps -> light ATA
  2. Returns null if there’s nothing to load (idempotent)
  3. Creates the ATA if it doesn’t exist
Find the source code here.

Get Started

1

Load Compressed Tokens to Hot Balance

Install packages in your working directory:
npm install @lightprotocol/stateless.js@alpha \
            @lightprotocol/compressed-token@alpha
Install the CLI globally:
npm install -g @lightprotocol/zk-compression-cli@alpha
# Start local test-validator in separate terminal
light test-validator
import { Keypair } from "@solana/web3.js";
import { createRpc, bn } from "@lightprotocol/stateless.js";
import {
  createMint,
  mintTo,
  loadAta,
  getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";

async function main() {
  const rpc = createRpc();
  const payer = Keypair.generate();
  const sig = await rpc.requestAirdrop(payer.publicKey, 10e9);
  await rpc.confirmTransaction(sig);

  // Setup: Get compressed tokens (cold storage)
  const { mint } = await createMint(rpc, payer, payer.publicKey, 9);
  await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000));

  // Load compressed tokens to hot balance
  const ctokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey);
  const tx = await loadAta(rpc, ctokenAta, payer, mint, payer);

  console.log("Tx:", tx);
}

main().catch(console.error);