Create Token Pools for Compression to Existing Mints
Guide to create token pools for compressed tokens for SPL mints with createTokenPool(), troubleshooting and advanced configurations.
Create a token for compression fo an existing SPL mint. createTokenPool() requires only fee_payer and has no mint authority constraint.
The token pool account itself requires rent, but individual compressed token accounts are rent-free.
Report incorrect code
Copy
Ask AI
// Creates token pool account for existing SPL mintconst transactionSignature = await createTokenPool( rpc, payer, mint,);
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.
# Start a local test validatorlight test-validator## ensure you have the Solana CLI accessible in your system PATH
Report incorrect code
Copy
Ask AI
// createRpc() defaults to local test validator endpointsimport { 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();
Replace <your-api-key> with your actual API key. Get your API key here, if you don’t have one yet.
Report incorrect code
Copy
Ask AI
import { createRpc } from "@lightprotocol/stateless.js";// Helius exposes Solana and Photon RPC endpoints through a single URLconst RPC_ENDPOINT = "https://devnet.helius-rpc.com?api-key=<your_api_key>";const connection = createRpc(RPC_ENDPOINT, RPC_ENDPOINT, RPC_ENDPOINT);console.log("Connection created!");console.log("RPC Endpoint:", RPC_ENDPOINT);
const mints = [ new PublicKey("MINT_1_ADDRESS"), new PublicKey("MINT_2_ADDRESS"), new PublicKey("MINT_3_ADDRESS"),];for (const mint of mints) { try { const poolTx = await createTokenPool(rpc, payer, mint); console.log(`Pool created for ${mint.toBase58()}:`, poolTx); } catch (error) { console.log(`Failed for ${mint.toBase58()}:`, error.message); }}
Create Pool with Token-2022
Create token pools for Token-2022 mints:
Report incorrect code
Copy
Ask AI
import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token';const poolTx = await createTokenPool( rpc, payer, mint, // Token-2022 mint undefined, TOKEN_2022_PROGRAM_ID,);