mintTo() function creates compressed token accounts for recipients and increases the mint’s token supply. Only the mint authority can perform this operation.
Before minting compressed tokens, you need an SPL mint with a token pool for compression. This token pool can be created for new SPL mints via createMint() or added to existing SPL mints via createTokenPool().
function-mint-compressed-tokens.ts
Full Code Example
Prerequisites
Make sure you have dependencies and developer environment set up!Prerequisites & Setup
Prerequisites & Setup
DependenciesAlternatives:Developer EnvironmentBy default, this guide uses Localnet.Alternative: Using DevnetFollow these steps to create an RPC Connection. Replace
<your_api_key> with your API key before running.Get your API Key here, if you don’t have one yet.
Minting Compressed Tokens
Run this script to mint compressed tokens to a recipient!mint-compressed-tokens.ts
Troubleshooting
TokenPool not found
TokenPool not found
createMint.TokenPool mint does not match the provided mint
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:
Amount and toPubkey arrays must have the same length
Amount and toPubkey arrays must have the same length
When minting to multiple recipients, ensure arrays are the same size.
Advanced Configuration
Mint to Multiple Recipients
Mint to Multiple Recipients
With Custom Mint Authority
With Custom Mint Authority