{"record":{"id":"937e86bbf3b2b47f","repo":"nautechsystems/nautilus_trader","slug":"eth-getcode-returned-no-result","errorCode":null,"errorMessage":"eth_getCode returned no result","messagePattern":"eth_getCode returned no result","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":419,"sourceCode":"            )\n            .await?;\n        let value = result.ok_or_else(|| anyhow::anyhow!(\"eth_getStorageAt returned no result\"))?;\n        B256::from_str(&value)\n            .map_err(|_| anyhow::anyhow!(\"Failed to parse eth_getStorageAt response\"))\n    }\n\n    async fn get_code_with_block(\n        &self,\n        address: &Address,\n        block: Option<u64>,\n    ) -> anyhow::Result<Bytes> {\n        let result: Option<String> = self\n            .execute_execution_rpc_call(\n                \"eth_getCode\",\n                serde_json::json!([address, block_parameter(block)]),\n            )\n            .await?;\n        let hex_string = result.ok_or_else(|| anyhow::anyhow!(\"eth_getCode returned no result\"))?;\n        let stripped = hex_string.strip_prefix(\"0x\").unwrap_or(&hex_string);\n        let bytes = hex::decode(stripped)\n            .map_err(|e| anyhow::anyhow!(\"Failed to decode eth_getCode result: {e}\"))?;\n        Ok(Bytes::from(bytes))\n    }\n\n    /// Returns the next nonce for the given address via `eth_getTransactionCount`\n    /// with the `pending` tag, making the pending pool state authoritative.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the RPC call fails or the result is missing or malformed.\n    pub async fn get_transaction_count_pending(&self, address: &Address) -> anyhow::Result<u64> {\n        let result: Option<String> = self\n            .execute_execution_rpc_call(\n                \"eth_getTransactionCount\",\n                serde_json::json!([address, \"pending\"]),\n            )","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L401-L437","documentation":"The eth_getCode RPC call returned a JSON-RPC result of null (no 'result' field value) for the requested address and block; the node provided no code payload, so the address's deployed bytecode cannot be read and the call fails rather than treating null as empty code.","triggerScenarios":"Calling get_code/get_code_at against a node that returns null for the code field — typically a non-compliant node, an error swallowed by a proxy, or a request for a block that is not available (pruned node returning null).","commonSituations":"Pruned/archival mismatch: requesting code at an old block on a non-archival node; misconfigured endpoint returning null on internal errors.","solutions":["Confirm the node serves state at the requested block (archival node for historical queries)","Retry with block=None (latest) to see if the address has code","Validate the endpoint returns proper JSON-RPC responses (test eth_getCode via curl)","Switch to a node/provider that returns 0x for accounts instead of null"],"exampleFix":"// before: historical block on non-archival node\nlet code = client.get_code_at(&addr, Some(old_block)).await?;\n// after: fall back to latest, or ensure archival node\nlet code = match client.get_code_at(&addr, Some(old_block)).await {\n    Ok(c) => c,\n    Err(_) => client.get_code(&addr).await?,\n};","handlingStrategy":"fallback","validationCode":"// check node can serve state at the requested block first\n// e.g. call eth_getBlockByNumber(block, false); if null, block is unavailable","typeGuard":null,"tryCatchPattern":"let code = match client.get_code_at(&addr, Some(block)).await {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"no result\") => {\n        client.get_code(&addr).await? // fall back to latest state\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Use archival nodes for historical state queries","Verify block availability on the node before state queries at old heights","Fall back to latest-state queries where semantically acceptable","Avoid pruned nodes for deep-history lookups"],"tags":["rpc","null-result","bytecode","blockchain"],"backgroundTag":"empty-result-set","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"}