Skip to main content
When building custom transactions with /build, you may hit the 1232-byte transaction size limit, especially when adding custom instructions alongside the swap. The techniques below help, in order of how directly they target size.
If your wallet, SDK, and RPC support it, prefer a Solana v1 transaction (transactionVersion=1). It raises the size limit to 4096 bytes and inlines up to 64 accounts without Address Lookup Tables, so it is usually the simpler fix than the techniques below, and Jupiter’s newer features are built with the larger v1 size in mind. maxBytes is not supported with v1, because v1 already has the larger budget.

Budget transaction bytes with maxBytes

Set maxBytes (integer, 1-1232) to ask Metis for a route whose swap transaction fits a byte budget, leaving room for your own instructions.
  • Sizing is deterministic, not an estimate, which makes maxBytes more accurate than maxAccounts: Metis builds and serializes the route to measure it, rather than guessing from the account count. The swap it returns for your budget always comes in at or below maxBytes.
  • maxBytes counts the bare swap only. Anything you add on top is not counted, so your final transaction can still exceed maxBytes:
    • Request parameters that add to the transaction, such as payer, feeAccount, destination accounts, close authority, cashback, or tipAmount.
    • Your own instructions, extra signers, and your own Address Lookup Tables.
  • Set maxBytes below 1232 to leave room for whatever you add.
Leave headroom below 1232 for what you add, then confirm: serialize your final transaction, and if it is over 1232 bytes, lower maxBytes by the difference and request again.As a rough guide, each account you add costs 1 byte if it is in your lookup table and 32 bytes if not, each extra signer (such as a separate payer) costs about 96 bytes and cannot live in a lookup table, and your own instruction data costs its full byte length. See the API reference for the full parameter.
maxBytes is new and still experimental. Please report any issues.
  • maxBytes=1232 is not a no-op, and tends to return a larger transaction than omitting the parameter: without a limit Metis uses an account-count model, and any maxBytes value switches it to the byte sizer, which fills the available space. Setting 1232 and then adding your own instructions overflows the 1232-byte limit, since your additions are not counted.
  • A tight budget can worsen pricing on large trades, the same way maxAccounts can: the router has fewer DEXes and splits to work with. At small sizes the difference is usually negligible. Test pricing before committing to a low value.
  • If the budget is too small for any route, /build returns No routes found (HTTP 400), which looks identical to a pair with no liquidity. Raise maxBytes and retry to tell them apart.

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. Reach for this when your constraint is the account count itself (for example CPI account limits), or as a retry lever alongside maxBytes. When the constraint is transaction size, prefer maxBytes, which targets bytes directly.
Setting maxAccounts too low will severely degrade routing quality. Very low values (for example below 50) can result in no route found or significantly worse pricing, because the router cannot access enough DEXes or split the route across multiple pools. Start with a moderate reduction (for example reducing by 2 and retrying) and test pricing impact before going lower.

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:
  1. Check onchain if the associated token accounts already exist
  2. If they exist, omit those setup instructions from your transaction
  3. 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.