Skip to main content

  1. Associated light-token accounts are Solana accounts that hold token balances of light, SPL, or Token 2022 mints.
  2. The address for light-ATAs is deterministically derived with the owner’s address, compressed token program ID, and mint address.
  3. Associated light-token accounts implement a default rent config:
    1. At account creation, you pay ~17,208 lamports
      and (the rent-exemption is sponsored by the protocol)
    2. Transfers keep the account funded via top-ups. The transaction payer tops up 776 lamports when the account’s rent is below 3h.
  1. The rent-exemption for light account creation is sponsored by the Light Token Program.
  2. Transaction payer’s pay rent
    to keep accounts “active”.
  3. “Inactive” accounts (rent below one epoch) get automatically compressed.
  4. The account’s state is cryptographically preserved and will be loaded into hot account state in-flight, when the account is used again.
The hot state fee is paid for by the transaction payer when writing to the respective account.

Get Started

The createAtaInterface function creates an associated light-token account in a single call.Compare to SPL:
Find the source code here.
1

Create Associated Token Account

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 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,
    createAtaInterface,
} 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();

    const { mint } = await createMintInterface(rpc, payer, payer, null, 9);

    const owner = Keypair.generate();
    const ata = await createAtaInterface(rpc, payer, mint, owner.publicKey);

    console.log("ATA:", ata.toBase58());
})();

Next Steps

Learn how to mint light-tokens