nautechsystems/nautilus_trader · error
Maximum transaction cost overflow
Error message
Maximum transaction cost overflow
What it means
Immediately after computing max gas cost, the client adds the transaction `value` to it with checked U256 arithmetic to obtain the maximum total cost used for the native-balance check. If `value + max_gas_cost` overflows U256, the addition returns None and this error aborts the pre-sign flow.
Solutions
- Validate that the transaction `value` is within the wallet/chain's realistic bounds before calling the sign path.
- Fix unit conversion so the value is expressed in wei correctly (ether -> wei with 10^18 factor).
- Reject or sanitize upstream intent payloads carrying implausible values.
- Sanity-check max_fee_per_gas / gas_limit as in the sibling overflow error so max_gas_cost is not inflated.
Example fix
// before
let value = U256::from_dec_str("115792089237316195423570985008687907853269984665640564039457584007913129639935")?; // U256::MAX
// after
let value = U256::from(1_000_000_000_000_000_000u64); // 1 ETH in wei, sanity-checked upstream Defensive patterns
Strategy: validation
Validate before calling
pub fn transaction_cost_fits(value: U256, max_gas_cost: U256) -> bool {
value.checked_add(max_gas_cost).is_some()
} Try / catch
match result {
Err(e) if e.to_string().contains("Maximum transaction cost overflow") => {
reject_intent(intent_id, "implausible transaction value");
}
other => other?,
} Prevention
- Validate transaction value against per-intent maxima upstream.
- Use type-safe unit conversion (ether -> wei) helpers, not hand-rolled exponent math.
- Treat near-U256-max values as malformed input and reject early.
When it happens
Trigger: Calling the sign path with a `value` (msg.value in wei) so large that adding the maximum gas cost exceeds U256::MAX — e.g. a value near 2^256 from a unit conversion bug or corrupted intent payload.
Common situations: Wei/ether unit conversion mistakes when constructing the transaction value; corrupted or malicious intent data; combining a near-U256-max value with any non-zero gas cost.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Maximum gas cost overflow
- Executed amount scaling overflow
- Order amount overflow scaling quantity to raw token units
- Order amount scaling overflow
- amount overflows U256 while scaling from to decimals
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/681ddaf107184035.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/blockchain/src/execution/client.rs:2377
self.verification
.verify_gas_estimate(
&self.wallet_address,
&to,
value,
&input,
decision_header.number,
)
.await,
"pre-sign gas estimate",
)?;
let gas_estimate = gas_estimate_verification.value;
let gas_limit = derive_gas_limit(gas_estimate, self.gas_buffer_bps, self.gas_limit)?;
let max_gas_cost = U256::from(gas_limit)
.checked_mul(U256::from(max_fee_per_gas))
.ok_or_else(|| anyhow::anyhow!("Maximum gas cost overflow"))?;
let max_transaction_cost = value
.checked_add(max_gas_cost)
.ok_or_else(|| anyhow::anyhow!("Maximum transaction cost overflow"))?;
let native_balance_verification = required_verification(
self.verification
.verify_balance(&self.wallet_address, decision_header.number)
.await,
"pre-sign native balance",
)?;
let native_balance = native_balance_verification.value;
if native_balance < max_transaction_cost {
anyhow::bail!(
"Native currency balance {native_balance} wei is below maximum transaction cost {max_transaction_cost} wei"
);
}
let decision_height = Some(decision_header.number);
let mut decisions = vec![
verification_decision(&chain_id_verification, None, None),
verification_decision(
&decision_header_verification,View on GitHub (pinned to 18893faf8b)