{"record":{"id":"ab73b28cfb1e82a6","repo":"nautechsystems/nautilus_trader","slug":"eth-gettransactionreceipt-returned-a-receipt-with","errorCode":null,"errorMessage":"eth_getTransactionReceipt returned a receipt with a mismatched transaction hash","messagePattern":"eth_getTransactionReceipt returned a receipt with a mismatched transaction hash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":730,"sourceCode":"    /// A `null` result maps to `Ok(None)`: the transaction is pending and no receipt\n    /// exists yet.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the RPC call fails or the response is malformed.\n    pub async fn get_transaction_receipt(\n        &self,\n        tx_hash: &B256,\n    ) -> anyhow::Result<Option<RpcTransactionReceipt>> {\n        let receipt: Option<RpcTransactionReceipt> = self\n            .execute_execution_rpc_call(\"eth_getTransactionReceipt\", serde_json::json!([tx_hash]))\n            .await?;\n\n        if receipt\n            .as_ref()\n            .is_some_and(|receipt| receipt.transaction_hash != *tx_hash)\n        {\n            anyhow::bail!(\n                \"eth_getTransactionReceipt returned a receipt with a mismatched transaction hash\"\n            );\n        }\n\n        Ok(receipt)\n    }\n\n    /// Returns a full transaction by hash.\n    ///\n    /// A `null` result maps to `Ok(None)` while the transaction is not available.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the RPC call fails, the response is malformed, or the returned hash\n    /// does not match `tx_hash`.\n    #[cfg(feature = \"hypersync\")]\n    #[allow(\n        dead_code,","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L712-L748","documentation":"Safety check in `get_transaction_receipt`: after fetching a receipt via `eth_getTransactionReceipt`, the library verifies the returned receipt's `transaction_hash` matches the requested hash and fails otherwise. This guards against buggy or malicious RPC providers (or load balancers) returning a receipt for a different transaction.","triggerScenarios":"Calling `get_transaction_receipt(tx_hash)` (typically via `poll_for_receipt`) and the node responds with a receipt whose `transaction_hash` differs from the requested one.","commonSituations":"Misbehaving or caching RPC proxy; provider bug after an upgrade; hash serialization mismatch in a custom middleware that rewrites hashes.","solutions":["Switch to a reputable RPC provider/endpoint and retry the lookup.","Bypass any caching/mutating proxy or middleware in the RPC path.","Check adapter/provider version for known hash-serialization bugs and update.","If polling, ensure the same tx hash string (case/0x-prefix) is used consistently."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Sanity-check the requested hash before lookup\nfn valid_tx_hash(h: &str) -> bool { h.len() == 66 && h.starts_with(\"0x\") && h[2..].chars().all(|c| c.is_ascii_hexdigit()) }","typeGuard":"fn receipt_matches(receipt: &TransactionReceipt, tx_hash: &Hash) -> bool {\n    receipt.transaction_hash == *tx_hash\n}","tryCatchPattern":"let receipt = match rpc.get_transaction_receipt(tx_hash).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"mismatched transaction hash\") => {\n        warn!(\"provider returned wrong receipt; retrying on fallback\");\n        fallback_rpc.get_transaction_receipt(tx_hash).await?\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Use reputable RPC providers; avoid opaque caching proxies in the path","Verify response integrity when adding response-mutating middleware","Keep adapter/provider dependencies updated for known serialization bugs","Pin an explicit fallback provider for integrity-critical lookups"],"tags":["evm","rpc","integrity-check","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}