Skip to main content
The mint account itself requires rent (like regular SPL mints), but individual compressed token accounts are rent-free. 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.

Get Started

1

Create a Mint Account with Token Pool for Compression

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 { createMint } 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, transactionSignature } = await createMint(
        rpc,
        payer,
        payer.publicKey,
        9
    );

    console.log("Mint:", mint.toBase58());
    console.log("Tx:", transactionSignature);
})();

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

How to Add Token Pools for Existing Mints