{"record":{"id":"4865d1b28f0a6623","repo":"nautechsystems/nautilus_trader","slug":"native-currency-balance-native-balance-wei-is-be","errorCode":null,"errorMessage":"Native currency balance {native_balance} wei is below maximum transaction cost {max_transaction_cost} wei","messagePattern":"Native currency balance (.+?) wei is below maximum transaction cost (.+?) wei","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":2387,"sourceCode":"        )?;\n        let gas_estimate = gas_estimate_verification.value;\n        let gas_limit = derive_gas_limit(gas_estimate, self.gas_buffer_bps, self.gas_limit)?;\n        let max_gas_cost = U256::from(gas_limit)\n            .checked_mul(U256::from(max_fee_per_gas))\n            .ok_or_else(|| anyhow::anyhow!(\"Maximum gas cost overflow\"))?;\n        let max_transaction_cost = value\n            .checked_add(max_gas_cost)\n            .ok_or_else(|| anyhow::anyhow!(\"Maximum transaction cost overflow\"))?;\n        let native_balance_verification = required_verification(\n            self.verification\n                .verify_balance(&self.wallet_address, decision_header.number)\n                .await,\n            \"pre-sign native balance\",\n        )?;\n        let native_balance = native_balance_verification.value;\n\n        if native_balance < max_transaction_cost {\n            anyhow::bail!(\n                \"Native currency balance {native_balance} wei is below maximum transaction cost {max_transaction_cost} wei\"\n            );\n        }\n        let decision_height = Some(decision_header.number);\n        let mut decisions = vec![\n            verification_decision(&chain_id_verification, None, None),\n            verification_decision(\n                &decision_header_verification,\n                decision_height,\n                decision_height,\n            ),\n            verification_decision(&deployment_verification, decision_height, decision_height),\n            verification_decision(&priority_fee_verification, None, None),\n            verification_decision(&gas_estimate_verification, decision_height, decision_height),\n            verification_decision(\n                &native_balance_verification,\n                decision_height,\n                decision_height,","sourceCodeStart":2369,"sourceCodeEnd":2405,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L2369-L2405","documentation":"Pre-sign, the client verifies the wallet's native currency balance (in wei) and bails if it is below the maximum estimated transaction cost. This guard prevents broadcasting a transaction that cannot pay its gas, which would either fail at inclusion or waste an in-flight slot.","triggerScenarios":"Submitting a transaction when the signer address's native balance (ETH etc.) is less than the computed max cost (gas limit × max fee per gas + value). The balance check itself is verified via the pre-sign native balance verification.","commonSituations":"Wallet drained or funds still bridging; gas price spiked so max cost exceeds balance; using the wrong chain/wallet with low balance; value transfer included on top of gas making total cost exceed balance.","solutions":["Fund the signer address with enough native currency to cover max cost plus headroom","Lower the transaction's value or gas limit if possible","Re-check the current gas price and resubmit when fees drop","Confirm the correct chain and wallet address are configured"],"exampleFix":"// before\nclient.submit_order(order).await?;\n// after\nlet balance = client.native_balance(signer_address).await?;\nlet max_cost = client.max_transaction_cost(&order).await?;\nanyhow::ensure!(balance > max_cost, \"fund wallet: need {max_cost} wei, have {balance}\");\nclient.submit_order(order).await?;","handlingStrategy":"validation","validationCode":"let balance = client.native_balance(signer_address).await?;\nlet cost = client.max_transaction_cost(&tx).await?;\nanyhow::ensure!(balance > cost + headroom, \"need {} wei, have {}\", cost, balance);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Monitor signer wallet balance and alert below a threshold","Recompute max cost from live gas prices before each submission","Keep a funding buffer above expected worst-case gas","Confirm chain id so you check the right network's balance"],"tags":["balance","gas","insufficient-funds","blockchain"],"backgroundTag":"value-out-of-range","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"}