Documentation Index
Fetch the complete documentation index at: https://luminouslabs-cc5545c6-feat-add-zk.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
-
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
-
Returns
null if there’s nothing to load (idempotent)
-
Creates the ATA if it doesn’t exist
Find the source code here.
Get Started
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
Install packages in your working directory:yarn add @lightprotocol/stateless.js@alpha \
@lightprotocol/compressed-token@alpha
Install the CLI globally:yarn global add @lightprotocol/zk-compression-cli@alpha
Install packages in your working directory:pnpm add @lightprotocol/stateless.js@alpha \
@lightprotocol/compressed-token@alpha
Install the CLI globally:pnpm add -g @lightprotocol/zk-compression-cli@alpha
# start local test-validator in a separate terminal
light test-validator
In the code examples, use createRpc() without arguments for localnet.
Get an API key from Helius and add to .env:API_KEY=<your-helius-api-key>
In the code examples, use createRpc(RPC_URL) with the devnet URL.
import "dotenv/config";
import { Keypair } from "@solana/web3.js";
import { createRpc, bn } from "@lightprotocol/stateless.js";
import {
createMint,
mintTo,
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!}`;
// localnet:
// const RPC_URL = undefined;
const payer = Keypair.fromSecretKey(
new Uint8Array(
JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
)
);
(async function () {
// devnet:
const rpc = createRpc(RPC_URL);
// localnet:
// const rpc = createRpc();
// 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);
})();
import "dotenv/config";
import { Keypair } from "@solana/web3.js";
import {
createRpc,
bn,
buildAndSignTx,
sendAndConfirmTx,
} from "@lightprotocol/stateless.js";
import {
createMint,
mintTo,
createLoadAtaInstructions,
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 () {
// Setup: mint directly to cold state
const { mint } = await createMint(rpc, payer, payer.publicKey, 9);
await mintTo(rpc, payer, mint, payer.publicKey, payer, bn(1000));
const ctokenAta = getAssociatedTokenAddressInterface(mint, payer.publicKey);
// load from cold to hot state
const ixs = await createLoadAtaInstructions(
rpc,
ctokenAta,
payer.publicKey,
mint,
payer.publicKey
);
if (ixs.length === 0) return console.log("Nothing to load");
const blockhash = await rpc.getLatestBlockhash();
const tx = buildAndSignTx(ixs, payer, blockhash.blockhash);
const signature = await sendAndConfirmTx(rpc, tx);
console.log("Tx:", signature);
})();