mintTo() function creates compressed token accounts for recipients and increases the mint’s token supply. Only the mint authority can perform this operation.
function-mint-compressed-tokens.ts
Full Code Example
1
Prerequisites
Make sure you have dependencies and developer environment set up!Prerequisites & Setup
Prerequisites & Setup
DependenciesDeveloper Environment
- npm
- yarn
- pnpm
- Localnet
- Devnet
By default, all guides use Localnet.
- npm
- yarn
- pnpm
2
Minting Compressed Tokens
Run this script to mint compressed tokens to a recipient!mint-compressed-tokens.ts
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
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().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