Tx Doctor / Solana error library / Exceeded token max
Solana error: Exceeded token max (0x1781)
An exact-output swap needed more input than the maximum you allowed. The mirror image of 6018: here you fixed the amount you want out, so the variable is what you pay in.
Why it happens
- The price worsened between quote and execution, and because the output was fixed the program had to pull more input to reach it.
- A 'swap for exactly X tokens' flow was used on a volatile pair where the input cost moves quickly.
- tokenMax was computed from a quote that is now stale.
- Thin concentrated liquidity meant the last portion of the trade filled at a much worse rate, pushing total input over the cap.
How to fix it
- Re-quote and retry; exact-output swaps need fresher data than exact-input ones.
- Raise the input cap slightly, or switch the flow to exact-input if the exact output amount is not essential.
- Avoid exact-output on low-liquidity pools — the input side is the one that moves.
- If you are integrating, pass tokenMax as a computed ceiling from the quote plus tolerance, not as a fixed number.
What it looks like in the logs
Program whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc failed: custom program error: 0x1781 RPC simulation: Transaction simulation failed: Error processing Instruction: custom program error: 0x1781 Wallet UI: "Transaction failed" — custom program error 0x1781 (6017)
One failure, three places it shows up: the raw transaction log, the RPC simulation error, and the wallet's short message. Match on the code, never on the wording.
The same number means something else on another program
Anchor assigns custom error codes by enum order starting at 6000, so this number is local to this program. The rows below show what the very same number means on the other programs.
| Program | 0x1781 = 6017 |
|---|---|
| Jupiter | Exact-out amount not matched |
| Raydium CLMM | Price slippage check |
| Raydium LaunchLab | Token-2022 extension not supported |
What this means for your funds
Solana transactions are atomic: if any instruction fails, every state change in that transaction is reverted, so token balances end exactly where they started. The network fee is still charged, because validators did the work of executing and rejecting it. A failed transaction never moves your tokens to someone else.
Seeing this error right now? Paste your transaction signature and get the exact instruction, program and code that failed.
Diagnose my transaction