{"record":{"id":"65a9d0f1389109a1","repo":"nautechsystems/nautilus_trader","slug":"transaction-reverted-on-chain","errorCode":null,"errorMessage":"Transaction {} reverted on-chain","messagePattern":"Transaction (.+?) reverted on-chain","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":2206,"sourceCode":"            InclusionOutcome::Reverted(mut included) => {\n                included.finality.decisions.extend(\n                    verify_finalized_transaction(\n                        &included,\n                        &intent,\n                        prepared.nonce,\n                        &prepared.raw_tx,\n                        self,\n                        purpose.as_str(),\n                    )\n                    .await?,\n                );\n                self.commit_verified_finality(&included, TransactionStatus::Reverted, &[])\n                    .await?;\n                self.database\n                    .mark_execution_event_emitted(prepared.intent_id, \"terminal\")\n                    .await?;\n                self.release_slot();\n                anyhow::bail!(\"Transaction {} reverted on-chain\", included.tx_hash)\n            }\n            InclusionOutcome::Pending(message) => anyhow::bail!(message),\n        }\n    }\n\n    /// Claims the single in-flight slot before any preparation RPC call, so the `pending`\n    /// nonce read stays authoritative: a second transaction is rejected before it can sign.\n    fn claim_slot(&self, purpose: TransactionPurpose) -> anyhow::Result<()> {\n        let mut slot = self.in_flight.lock();\n        if let Some(in_flight) = *slot {\n            return Err(in_flight_limit_error(&in_flight));\n        }\n        *slot = Some(InFlightSlot::Preparing(purpose));\n        Ok(())\n    }\n\n    /// Runs the read-only pre-signing pipeline: chain ID verification, nonce selection, fee\n    /// and gas policy checks, transaction building, and local signing.","sourceCodeStart":2188,"sourceCodeEnd":2224,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L2188-L2224","documentation":"After waiting for inclusion, the transaction receipt shows status Reverted: the transaction was mined but its execution failed on-chain (e.g. the swap reverted). The client records a terminal Reverted status in the database, emits the event, releases the in-flight slot, and bails so the caller sees the failure.","triggerScenarios":"A submitted transaction (e.g. a swap or approval) was included in a block but executed with a revert — the EVM rolled back its effects while gas was still consumed.","commonSituations":"Slippage tolerance too tight so minAmountOut not met at execution time; token transfer/approval failing on-chain; pool price moved between quote and inclusion; insufficient balance at execution block.","solutions":["Read the revert reason from the receipt/trace to identify the on-chain failure","Widen slippage_bps or re-quote before resubmitting","Re-check balances, allowances, and pool state at current block before retry","Simulate the transaction pre-sign to catch reverts before spending gas"],"exampleFix":"// before\nlet quote = client.quote(pool, amount).await?;\nclient.submit_order(order_with(quote)).await?;\n// after\nlet quote = client.quote(pool, amount).await?;\nclient.prepare_and_simulate(quote, slippage_bps).await?; // pre-sign simulation\nclient.submit_order(order_with(quote)).await?;","handlingStrategy":"validation","validationCode":"// Pre-sign simulation catches most reverts before gas is spent\nlet sim = client.simulate_transaction(&tx).await?;\nanyhow::ensure!(sim.succeeded(), \"tx would revert: {:?}\", sim.reason);","typeGuard":null,"tryCatchPattern":"match res {\n    Err(e) if e.to_string().contains(\"reverted on-chain\") => {\n        let reason = client.fetch_revert_reason(tx_hash).await?;\n        // adjust slippage/state and resubmit\n    }\n    r => r?,\n}","preventionTips":["Always simulate before signing to catch reverts early","Re-quote immediately before submission and use sane slippage_bps","Verify balances and allowances at the latest block","Monitor receipt revert reasons to tune parameters"],"tags":["revert","transaction","blockchain","gas"],"backgroundTag":"http-error-response","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}