Skip to main content
  1. loadAta unifies tokens from multiple sources to a single ATA:
    • Compressed tokens (cold Light Tokens) -> Decompresses -> light ATA
    • SPL balance (if wrap=true) -> Wraps -> light ATA
    • Token 2022 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.
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
1

Unify Tokens to Light-ATA Balance

Install packages in your working directory:
npm install @lightprotocol/stateless.js@beta \
            @lightprotocol/compressed-token@beta
Install the CLI globally:
npm install -g @lightprotocol/zk-compression-cli@beta
# start local test-validator in a separate terminal
light test-validator
In the code examples, use createRpc() without arguments for localnet.
import "dotenv/config";
import { Keypair } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
    createMintInterface,
    mintToCompressed,
    loadAta,
    getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";
import { homedir } from "os";
import { readFileSync } from "fs";

// devnet:
// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
// const rpc = createRpc(RPC_URL);
// localnet:
const rpc = createRpc();

const payer = Keypair.fromSecretKey(
    new Uint8Array(
        JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
    )
);

(async function () {
    // Inactive Light Tokens are cryptographically preserved on the Solana ledger
    // as compressed tokens (cold storage)
    // Setup: Get compressed tokens in light-token associated token account
    const { mint } = await createMintInterface(rpc, payer, payer, null, 9);
    await mintToCompressed(rpc, payer, mint, payer, [
        { recipient: payer.publicKey, amount: 1000n },
    ]);

    // Load compressed tokens to light associated token account (hot balance)
    const lightTokenAta = getAssociatedTokenAddressInterface(
        mint,
        payer.publicKey
    );
    const tx = await loadAta(rpc, lightTokenAta, payer, mint, payer);

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

Payments overview

Wrap and unwrap


Didn’t find what you were looking for?

Reach out! Telegram | email | Discord