transfer() function moves compressed tokens between accounts.
- SPL token transfers that update the existing account
- Compressed token transfers consume input accounts from the sender and create new output accounts for sender and recipient with updated balances.
function-transfer-compressed-tokens.ts
Get Started
1
Transfer Compressed Tokens
Installation
Installation
- npm
- yarn
- pnpm
- SDK 2.0 (token-interface)
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 for transfer
Insufficient balance for transfer
The sender doesn’t have enough compressed tokens for the requested transfer amount.
Account limit exceeded
Account limit exceeded
The transfer requires more than 4 compressed accounts, which exceeds the transaction limit.
Advanced Configuration
Transfer to Multiple Recipients
Transfer to Multiple Recipients
Transfer to multiple recipients in separate transactions: