Skip to main content
The mint account itself requires rent (like regular SPL mints), but individual compressed token accounts are rent-free.
Compressed tokens use an SPL mint with token pool for compression. The token pool locks SPL tokens while compressed and releases them when decompressed. Create a token pool for an existing SPL mint with createTokenPool() or use createMint() to create a new one from scratch.
// Create SPL mint with token pool for compression
const { mint, transactionSignature } = await createMint(
    rpc,
    payer,
    mintAuthority.publicKey,
    decimals,
);
Best Practice: Each mint supports a maximum of 4 token pools total. During compression/decompression, token pools get write-locked. Use addTokenPools() to create additional pools that increase per-block write-lock capacity.

Full Code Example

1

Prerequisites

Make sure you have dependencies and developer environment set up!
Dependencies
npm install @lightprotocol/stateless.js@alpha \
            @lightprotocol/compressed-token@alpha
Developer Environment
By default, all guides use Localnet.
npm install -g @lightprotocol/zk-compression-cli@alpha
# Start a local test validator
light test-validator

## ensure you have the Solana CLI accessible in your system PATH
// createRpc() defaults to local test validator endpoints
import {
  Rpc,
  createRpc,
} from "@lightprotocol/stateless.js";

const connection: Rpc = createRpc();

async function main() {
  let slot = await connection.getSlot();
  console.log(slot);

  let health = await connection.getIndexerHealth(slot);
  console.log(health);
  // "Ok"
}

main();
2

Create SPL Mint with Token Pool for Compression

Run this script to create a mint account with token pool for compression.
create-mint.ts
// 1. Setup funded payer and connect to local validator
// 2. Create SPL mint with token pool for compression via createMint()

import { Keypair } from '@solana/web3.js';
import { createRpc } from '@lightprotocol/stateless.js';
import { createMint } from '@lightprotocol/compressed-token';

async function createCompressedMint() {
    // Step 1: Setup funded payer and connect to local validator
    const rpc = createRpc(); // defaults to localhost:8899
    const payer = Keypair.generate();
        const airdropSignature = await rpc.requestAirdrop(payer.publicKey, 1000000000); // 1 SOL
    await rpc.confirmTransaction(airdropSignature);

    // Step 2: Call createMint() to create mint account and token pool for compression
    const { mint, transactionSignature } = await createMint(
        rpc,
        payer,
        payer.publicKey, // mint authority
        9
    );
    console.log("SPL mint with token pool for compression created");
    console.log("Mint address:", mint.toBase58());
    console.log("Transaction:", transactionSignature);


    return { mint, transactionSignature };
}

createCompressedMint().catch(console.error);

Advanced Configuration

Customize who can mint new compressed tokens.
const mintAuthority = Keypair.generate();

const { mint, transactionSignature } = await createMint(
    rpc,
    payer,
    mintAuthority.publicKey,
    9,
);
Customize who can freeze/thaw compressed token accounts.
const freezeAuthority = Keypair.generate();

const { mint, transactionSignature } = await createMint(
    rpc,
    payer,
    payer.publicKey, // mint authority
    9, // decimals
    Keypair.generate(), // mint keypair
    undefined, // confirm options
    undefined, // token program ID
    freezeAuthority.publicKey, // freeze authority
);

Next Steps

Learn how to create additional compressed token pools for your SPL mint to increase write-lock limits.