After compression, empty token accounts can now be closed to reclaim rent with
closeAccount().Get Started
Compress SPL Token Accounts
Installation
Installation
- npm
- yarn
- pnpm
Install packages in your working directory:Install the CLI globally:
- Localnet
- Devnet
In the code examples, use
createRpc() without arguments for localnet.The SPL mint must have an SPL Interface PDA for compression.
The script creates it for you.For development, create a new mint with SPL interface via
The script creates it for you.For development, create a new mint with SPL interface via
createMint() or add an SPL interface to an existing mint via createSplInterface().Troubleshooting
Insufficient balance in token account
Insufficient balance in token account
The token account doesn’t have enough tokens for the operation.
Remaining amount exceeds balance
Remaining amount exceeds balance
The
remainingAmount parameter exceeds the current account balance.Advanced Configuration
Partial Account Compression
Partial Account Compression
Compress most tokens while leaving some in SPL format:
Compress Multiple Accounts
Compress Multiple Accounts
Compress several token accounts for the same mint: