SPL
Documentation

Batch Operations

Efficiently process multiple token operations in single transactions.

Transaction Batching

Solana transactions can contain multiple instructions, allowing you to perform several operations atomically in a single transaction.

Single Transaction Benefits

Efficient
  • Lower total transaction fees
  • Atomic execution (all or nothing)
  • Reduced network congestion
  • Faster overall processing

Transaction Limits

Constraints
Max Instructions~64 per transaction
Compute Units1.4M per transaction
Transaction Size1232 bytes max
Common Batch Scenarios

Token Creation + Initial Distribution

Create token and immediately distribute to multiple recipients.

1. Create mint account
2. Create metadata account
3. Mint initial supply
4. Transfer to recipient A
5. Transfer to recipient B
6. Transfer to recipient C

Multi-Recipient Airdrops

Send tokens to multiple addresses in a single transaction.

Recipients per TX~20-30 (depending on setup)
Cost Savings~80% vs individual TXs

Authority Management

Update multiple authorities in a single atomic operation.

1. Set new mint authority
2. Set new freeze authority
3. Set new update authority
4. Revoke old authorities
Implementation Considerations

Planning Batch Operations

  • Calculate total compute units needed
  • Ensure all accounts are properly initialized
  • Consider instruction dependencies
  • Plan for partial failure scenarios

Error Handling

  • All instructions fail if any instruction fails
  • Use transaction simulation for testing
  • Implement retry logic for failed batches
  • Monitor transaction status carefully

Optimization Tips

  • Group similar operations together
  • Pre-create associated token accounts
  • Use lookup tables for address compression
  • Set appropriate priority fees for batches