> ## Documentation Index
> Fetch the complete documentation index at: https://luminouslabs-cc5545c6-indexing-tokens.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Toolkit to Index Light Token Accounts

> Light token accounts follow the same layout as SPL-token accounts, so you can reuse your existing parsers.

When a market becomes inactive, its token accounts and related PDAs will
be compressed automatically (cold storage).
The state is cryptographically preserved on the Solana ledger.
While compressed, pure on-chain lookups will return uninitialized.

Your indexer should keep tracking, quoting, and routing markets even if the
on-chain account shows `is_initialized: false`, `is_compressed: true`.
To trade a cold market, the first client must prepend an
idempotent decompress "warm up" instruction.

<Info>
  Find the source code
  [here](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/indexing-tokens).
</Info>

<Steps>
  <Step>
    ### Warm up a cold market and trade

    Prepend idempotent decompress instructions before your trade.
    `loadAta` returns null and `createLoadAtaInstructions` returns an empty array
    when the account is already hot, so this pattern is safe to use unconditionally.

    <Tabs>
      <Tab title="Action">
        ````typescript theme={null}
        import "dotenv/config";
        import { Keypair } from "@solana/web3.js";
        import { createRpc } from "@lightprotocol/stateless.js";
        import {
            createMintInterface,
            createAtaInterface,
            mintToCompressed,
            loadAta,
            transferInterface,
            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 }]);

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

            const senderAta = getAssociatedTokenAddressInterface(mint, payer.publicKey);
            const recipientAta = getAssociatedTokenAddressInterface(mint, recipient.publicKey);

            // Warm up: load compressed tokens to associated token account
            // Returns null if already hot
            await loadAta(rpc, senderAta, payer, mint, payer);

            // Transfer tokens from hot balance
            const tx = await transferInterface(
                rpc,
                payer,
                senderAta,
                mint,
                recipientAta,
                payer,
                500n,
            );

            console.log("Tx:", tx);
        })();```
        ````
      </Tab>

      <Tab title="Instruction">
        ````typescript theme={null}
        import "dotenv/config";
        import { Keypair } from "@solana/web3.js";
        import {
            createRpc,
            buildAndSignTx,
            sendAndConfirmTx,
        } from "@lightprotocol/stateless.js";
        import {
            createMintInterface,
            createAtaInterface,
            mintToCompressed,
            createLoadAtaInstructions,
            createTransferInterfaceInstruction,
            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 }]);

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

            const senderAta = getAssociatedTokenAddressInterface(mint, payer.publicKey);
            const recipientAta = getAssociatedTokenAddressInterface(
                mint,
                recipient.publicKey,
            );

            // Warm up: load compressed tokens (cold) to sender's hot balance
            // Returns [] if already hot — safe to call unconditionally
            const loadIxs = await createLoadAtaInstructions(
                rpc,
                senderAta,
                payer.publicKey,
                mint,
                payer.publicKey,
            );

            if (loadIxs.length > 0) {
                const blockhash = await rpc.getLatestBlockhash();
                const loadTx = buildAndSignTx(loadIxs, payer, blockhash.blockhash);
                await sendAndConfirmTx(rpc, loadTx);
            }

            // Trade: transfer from hot balance
            const transferIx = createTransferInterfaceInstruction(
                senderAta,
                recipientAta,
                payer.publicKey,
                500n,
            );

            const blockhash = await rpc.getLatestBlockhash();
            const tradeTx = buildAndSignTx([transferIx], payer, blockhash.blockhash);
            const signature = await sendAndConfirmTx(rpc, tradeTx);

            console.log("Tx:", signature);
        })();```
        ````
      </Tab>
    </Tabs>
  </Step>
</Steps>

# Stream light-mint accounts

<Card title="Toolkit to stream light-mints" icon="chevron-right" color="#0066ff" href="/light-token/toolkits/for-streaming-mints" horizontal />
