Create and Register a Mint Account for Compression
Complete guide to create and register an SPL token mint account for compression with createMint(), troubleshooting and advanced configurations.
Compressed tokens use an SPL mint that is registered with the compressed token program. Connect 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 operations, token pools get write-locked. Use addTokenPools() to create additional pools that increase per-block write-lock capacity.
Full Code Example
Create SPL Mint with Token Pool for Compression
Run this script to create a mint account with token pool for compression.
// 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 Configurations
Next Steps
Learn how to create additional compressed token pools for your SPL mint to increase write-lock limits.
Create Compressed Token Pools for Mint AccountsLast updated
Was this helpful?