RPC error InstructionError Custom: custom program error: 0x…
Last updated:
At a glance
| Property | Value |
|---|---|
| Applies to | Solana JSON-RPC |
| Display string | custom program error: {num:#x} |
| Defined by | The failing program |
| Anchor user errors | Start at 6000 (0x1770) |
| Retryable | Depends on the program: a slippage check can pass on fresh state |
Cause
Solana passes the code through without interpreting it: custom program error: 0x1771 means only that a program returned 6001. The same number means different things in different programs, so no universal table exists, and a search for the hex value alone often finds someone else's program. The log line above the failure identifies which program returned it.
Solution
- Find the program: in the logs, the last
Program <id> invokebeforefailedis the one that returned the code. - Convert hex to decimal.
0x1771is 6001. - On Anchor programs, user-defined errors start at 6000, so subtract 6000 to get the index in the
errorslist of the IDL. - Otherwise check the program's source or published error list. Ask for the IDL with the program's own tooling.
- When the error is a slippage check, rebuild with fresh state or a wider tolerance. Retrying the same bytes returns the same code.
Example
{
"err": {
"InstructionError": [
3,
{
"Custom": 6001
}
]
}
}FAQ
- What does custom program error 0x1 mean?
- It depends on the program. In the SPL Token program, code 1 is insufficient funds, but the same number in another program means something else. Always identify the program first.
- Why does error.data show Custom: 6001 when the message says 0x1771?
- They are the same number: the message prints hex, and the structured error prints decimal.