Use this file to discover all available pages before exploring further.
// Mint compressed tokens - mints SPL tokens to pool, creates compressed token accountsconst transactionSignature = await mintTo( rpc, payer, mint, // SPL mint with token pool for compression recipient, // recipient address (toPubkey parameter) payer, // mint authority amount,);
Make sure the SPL mint has a token pool for compression. The script creates this token pool for you.For development, you can create a new mint with token pool via createMint() or add a token pool to an existing mint via createTokenPool().
// Error message: "TokenPool not found. Please create a compressed token// pool for mint: [ADDRESS] via createTokenPool().
The mint does no have a token pool for compression. Ensure you created the mint using createMint.
// Create mint with token pool for compressionimport { createMint } from '@lightprotocol/compressed-token';const { mint } = await createMint(rpc, payer, payer.publicKey, 9);
TokenPool mint does not match the provided mint
The token pool info doesn’t correspond to the mint address. Ensure you’re fetching the correct pool:
// Get the correct token pool for your mintconst tokenPoolInfo = await getTokenPoolInfos(rpc, mint);
Amount and toPubkey arrays must have the same length
When minting to multiple recipients, ensure arrays are the same size.
// Mint different amounts to multiple recipientsconst recipients = [ Keypair.generate().publicKey, Keypair.generate().publicKey, Keypair.generate().publicKey,];const amounts = [ 1_000_000_000, // 1 token 2_000_000_000, // 2 tokens 500_000_000, // 0.5 tokens];const transactionSignature = await mintTo( rpc, payer, mint, // SPL mint with token pool for compression recipients, // array of recipients (toPubkey parameter) payer, // mint authority amounts, // array of amounts (amount parameter));
With Custom Mint Authority
Mint tokens using a custom mint authority with approveAndMintTo():
import { approveAndMintTo } from '@lightprotocol/compressed-token';// Mint tokens with a separate mint authorityconst transactionSignature = await approveAndMintTo( rpc, payer, mint, // SPL mint with token pool for compression recipient.publicKey, // recipient of minted tokens (toPubkey parameter) mintAuthority, // mint authority mintAmount,);