RPC error -32002: Transaction simulation failed
Last updated:
At a glance
| Property | Value |
|---|---|
| Applies to | Solana JSON-RPC |
| Code | -32002 (SEND_TRANSACTION_PREFLIGHT_FAILURE) |
| Method | sendTransaction, with skipPreflight false |
| Sent to the network | No |
| Reason lives in | error.data: err, logs, unitsConsumed |
| Not the same as | -32002 on EVM clients, which means a timeout in geth |
Cause
With preflight on, sendTransaction verifies signatures, checks the blockhash and simulates the transaction before broadcasting. If the simulation fails, the node returns -32002 with the simulation result attached and sends nothing to the network. The message repeats the first error, and the part you need is in data: the transaction error, the program logs and the compute units consumed. A failure here is usually a real problem with the transaction, or stale state in the bank you simulated against.
Solution
- Log
error.datain full.errgives the failing instruction andlogsshows the last program that ran. - Match the message to its page: Blockhash not found, computational budget exceeded, a custom program error or rent.
- Set
preflightCommitmentto the commitment you built against, usuallyconfirmed. The default isfinalized, which can be behind the state your transaction depends on. - Rebuild from fresh state if an account changed, then send again. Do not resend the same bytes after a deterministic failure.
Common reasons, and which layer owns them
The same code covers problems in very different places, so sort the failure before you change anything.
| In error.data | Layer | First move |
|---|---|---|
| BlockhashNotFound | Transaction | Fetch a new blockhash and re-sign |
| InsufficientFundsForFee | Fee payer | Fund the fee payer |
| InsufficientFundsForRent | Account | Fund the new account to its rent-exempt minimum |
| Custom error 0x… | Program | Look the number up in the program's IDL |
| ComputationalBudgetExceeded | Compute | Raise the compute unit limit |
Simulation on Triport
Preflight runs on every plan as part of sendTransaction. Calling simulateTransaction yourself needs Pro or higher. On lower plans, leave preflight on and read error.data, which gives you the same logs when a send fails.
Example
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32002,
"message": "Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1771",
"data": {
"err": {
"InstructionError": [
2,
{
"Custom": 6001
}
]
},
"logs": [
"Program log: ..."
],
"unitsConsumed": 48210
}
}
}FAQ
- Should I set skipPreflight to true to get rid of this?
- Not to fix it. Solana's guide recommends keeping preflight on. Skipping it makes sense when you have simulated yourself and want to save the second check, but a transaction that fails simulation will usually fail on chain too, and you pay the fee.
- Can a transaction fail preflight and still be fine?
- Yes, when the simulation ran against stale state. A trade that depends on an account changing, or a bank behind your blockhash, can fail in simulation and succeed moments later. Fix the commitment first.
- Was I charged?
- No. Preflight failed, so nothing was broadcast.