{"record":{"id":"92d074183403c377","repo":"nautechsystems/nautilus_trader","slug":"failed-to-decode-eth-call-response","errorCode":null,"errorMessage":"Failed to decode eth_call response","messagePattern":"Failed to decode eth_call response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":567,"sourceCode":"        {\n            if eth_call_error_is_revert(code, &message) {\n                return Ok(RpcCallResult::Reverted);\n            }\n            anyhow::bail!(\"eth_call RPC error {code}\");\n        }\n\n        if let Some(error) = parsed.error {\n            if eth_call_error_is_revert(error.code, &error.message) {\n                return Ok(RpcCallResult::Reverted);\n            }\n            anyhow::bail!(\"eth_call RPC error {}\", error.code);\n        }\n        let value = parsed\n            .result\n            .ok_or_else(|| anyhow::anyhow!(\"eth_call returned no result\"))?;\n        let stripped = value.strip_prefix(\"0x\").unwrap_or(&value);\n        let bytes = hex::decode(stripped)\n            .map_err(|_| anyhow::anyhow!(\"Failed to decode eth_call response\"))?;\n        Ok(RpcCallResult::Success(Bytes::from(bytes)))\n    }\n\n    /// Estimates the gas required for a transaction via `eth_estimateGas`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the RPC call fails (including node-side revert of the simulated\n    /// transaction) or the result is missing or malformed.\n    pub async fn estimate_gas(\n        &self,\n        from: &Address,\n        to: &Address,\n        value: U256,\n        data: &[u8],\n    ) -> anyhow::Result<u64> {\n        self.estimate_gas_with_block(from, to, value, data, None)\n            .await","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L549-L585","documentation":"Raised in `call_result_at` when the `result` string of a successful `eth_call` response is not valid hex (after stripping the `0x` prefix). The library expects the node to return a `0x`-prefixed hex-encoded ABI byte string and fails fast when the value cannot be hex-decoded into `Bytes`.","triggerScenarios":"The node returns a `result` that is not hex, e.g. an empty string, a non-hex error text smuggled into `result`, odd-length hex, or a decimal value from a non-conforming node.","commonSituations":"Custom or older execution clients that return unprefixed or odd-length hex; a node returning error text in `result` after an upstream proxy mangled the response; contract ABI output truncated by response size limits.","solutions":["Print/log the raw `result` string from the failing call to see what the node actually returned","Validate the node returns spec-compliant `0x`-prefixed hex (test with a simple eth_call against eth_chainId-style data)","Switch to a standards-compliant execution client (geth/reth/erigon) or mainstream provider","If odd-length hex comes from your own ABI encoding, fix the encoder before sending the request"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-validate node hex compliance with a known call\nlet v: serde_json::Value = send_raw(rpc_url, json!({\"jsonrpc\":\"2.0\",\"method\":\"eth_chainId\",\"id\":1})).await?;\nlet hex_ok = v[\"result\"].as_str().map(|s| s.starts_with(\"0x\") && hex::decode(&s[2..]).is_ok()).unwrap_or(false);","typeGuard":"fn is_hex_bytes(s: &str) -> bool {\n    let t = s.strip_prefix(\"0x\").unwrap_or(s);\n    !t.is_empty() && t.len() % 2 == 0 && t.chars().all(|c| c.is_ascii_hexdigit())\n}","tryCatchPattern":"match client.call_at(&tx, block).await {\n    Ok(res) => Ok(res),\n    Err(e) if e.to_string().contains(\"Failed to decode eth_call response\") => {\n        Err(anyhow!(\"node returned non-hex eth_call result; check client compliance: {e}\"))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Use standards-compliant execution clients (geth/reth/erigon) or mainstream providers","Sanity-check node hex output at startup with a probe call","Fix ABI encoders that emit odd-length or unprefixed hex","Beware proxies that rewrite response bodies between node and client"],"tags":["rpc","eth-call","hex","decoding"],"backgroundTag":"invalid-argument-format","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"}