/build, you may hit the 1232-byte transaction size limit, especially when adding custom instructions alongside the swap. Two techniques help.
Limit accounts with maxAccounts
Set maxAccounts (1-64, default 64) to limit the number of accounts in the swap route. Lower values produce simpler routes with fewer accounts.
- Your transaction already has many accounts from custom instructions
- You are hitting the transaction size limit
- You need room for CPI accounts
Remove no-op setup instructions
The/build response always includes createAssociatedTokenAccountIdempotent instructions in setupInstructions, even when the token accounts already exist. These are no-ops on existing accounts but still consume transaction space.
To reclaim that space:
- Check onchain if the associated token accounts already exist
- If they exist, omit those setup instructions from your transaction
- If they don’t exist, keep the instructions
This technique requires an additional RPC call (
getAccountInfo) per ATA you check. Depending on your RPC latency and how many ATAs the swap involves, this can add measurable overhead to your overall swap flow. Consider whether the space savings are worth the added latency for your use case, or batch the account checks in parallel or pre-swap.Related
- Build Custom Transactions for the full
/buildworkflow - Reduce Latency for faster routing
- Routing for how parameters affect routing
