{"record":{"id":"e1bf0ae6084ed814","repo":"nautechsystems/nautilus_trader","slug":"rpc-error","errorCode":null,"errorMessage":"RPC error {}: {}","messagePattern":"RPC error (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":177,"sourceCode":"            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to execute eth call RPC request: {e}\"))?;\n        let parsed =\n            serde_json::from_slice::<RpcNodeHttpResponse<T>>(bytes.as_ref()).map_err(|e| {\n                let raw_response = String::from_utf8_lossy(bytes.as_ref());\n                let preview = rpc_response_preview(&raw_response);\n                anyhow::anyhow!(\"Failed to parse eth call response: {e}\\nRaw response: {preview}\")\n            })?;\n\n        // Check for non-standard rate limit error (e.g., Infura)\n        // These responses have code/message at top level without jsonrpc field\n        if parsed.jsonrpc.is_none()\n            && let (Some(code), Some(message)) = (parsed.code, parsed.message)\n        {\n            anyhow::bail!(\"RPC provider error {code}: {message}\");\n        }\n\n        if let Some(error) = parsed.error {\n            anyhow::bail!(\"RPC error {}: {}\", error.code, error.message);\n        }\n\n        parsed\n            .result\n            .ok_or_else(|| anyhow::anyhow!(\"Response missing both result and error fields\"))\n    }\n\n    /// Creates a properly formatted `eth_call` JSON-RPC request object targeting a specific contract address with encoded function data.\n    #[must_use]\n    pub fn construct_eth_call(\n        &self,\n        to: &str,\n        call_data: &[u8],\n        block: Option<u64>,\n    ) -> serde_json::Value {\n        self.construct_eth_call_request(None, to, call_data, block)\n    }\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L159-L195","documentation":"The RPC node returned a standard JSON-RPC error object (`{\"error\":{\"code\":..,\"message\":..}}`) for the request. The code is the JSON-RPC error code (e.g. -32601 method not found, -32000 server error, -32005 limit exceeded) and the message is the node's own description. This indicates the request reached the node but was rejected at the protocol/execution level.","triggerScenarios":"Any `execute_rpc_call` / `get_balance_with_timeout` call where the node responds with a populated `error` field: unsupported method, invalid params, execution reverted, or node-side limit exceeded.","commonSituations":"Calling methods the node doesn't support (e.g. archive methods on a full node); malformed hex addresses or block tags in params; `eth_call` reverting due to contract logic; provider rejecting requests from unauthenticated or rate-limited projects.","solutions":["Parse the numeric code: -32601 means unsupported method (check endpoint capabilities); -32602 means invalid params (fix arguments); execution errors mean fix the call itself","Validate address/ABI parameters (checksummed 0x-hex, valid block tags) before sending","Retry only for transient codes (e.g. -32005 limit exceeded) with backoff; fail fast on -32601/-32602","Try a different RPC endpoint/node if the error is node-specific"],"exampleFix":"// before\nlet balance = rpc.get_balance_with_timeout(addr, None, timeout).await?;\n// after: validate params first\nlet addr = address.to_checksum(None); // ensure valid 0x hex\nif !addr.starts_with(\"0x\") || addr.len() != 42 { anyhow::bail!(\"invalid address\"); }\nlet balance = rpc.get_balance_with_timeout(addr, None, timeout).await?;","handlingStrategy":"try-catch","validationCode":"fn is_valid_address(a: &str) -> bool { a.starts_with(\"0x\") && a.len() == 42 && a[2..].chars().all(|c| c.is_ascii_hexdigit()) }","typeGuard":null,"tryCatchPattern":"match rpc_call().await {\n    Err(e) if e.to_string().contains(\"RPC error -32005\") => retry_with_backoff(),\n    Err(e) if e.to_string().contains(\"RPC error -32601\") => switch_endpoint(),\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Validate all params (addresses, block tags, hex encoding) before sending","Retry only transient codes (-32005, timeout-like); fail fast on -32601/-32602","Check endpoint capability docs for archive/unsupported methods"],"tags":["rpc","json-rpc","node-error","ethereum"],"backgroundTag":"api-error-response","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"}