{"record":{"id":"d2713b956aeb707d","repo":"FuelLabs/fuel-core","slug":"the-final-fee-is-too-big-to-fit-into-u64","errorCode":null,"errorMessage":"The final fee is too big to fit into `u64`","messagePattern":"The final fee is too big to fit into `u64`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/schema/tx/assemble_tx.rs","lineNumber":945,"sourceCode":"                        total_base_asset.checked_add(amount).ok_or_else(|| {\n                            anyhow::anyhow!(\n                        \"The total base asset amount used by the transaction is too big\"\n                    )\n                        })?;\n                }\n            }\n        }\n\n        loop {\n            let max_gas = self.tx.max_gas(&gas_costs, &fee_params);\n            let max_gas_with_reserve = max_gas.saturating_add(self.arguments.reserve_gas);\n\n            let final_gas = max_gas_with_reserve.min(max_gas_per_tx);\n            let final_fee =\n                gas_to_fee(final_gas, self.arguments.gas_price, gas_price_factor);\n            let final_fee = u64::try_from(final_fee)\n                .map_err(|_| {\n                    anyhow::anyhow!(\"The final fee is too big to fit into `u64`\")\n                })?\n                .saturating_add(self.tx.tip());\n\n            let need_to_cover = final_fee.saturating_add(self.base_asset_reserved);\n\n            if need_to_cover <= total_base_asset {\n                break\n            }\n\n            let remaining_input_slots = self.remaining_input_slots()?;\n            if remaining_input_slots == 0 {\n                return Err(CoinsQueryError::MaxCoinsReached {\n                    owner: fee_payer_account.owner(),\n                    asset_id: base_asset_id,\n                    collected_amount: total_base_asset.into(),\n                    max: self.arguments.consensus_parameters.tx_params().max_inputs(),\n                }\n                .into());","sourceCodeStart":927,"sourceCodeEnd":963,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/schema/tx/assemble_tx.rs#L927-L963","documentation":"After computing the final gas for the tx, the assembler converts gas to fee (gas_to_fee, computed in U256 using gas_price and the chain's gas_price_factor) and converts the result back to u64. The error fires when the computed fee exceeds u64::MAX — an arithmetic impossibility for sane gas prices.","triggerScenarios":"final_gas * gas_price / gas_price_factor > u64::MAX: an extreme gas_price combined with a large gas estimate, or a misconfigured gas_price_factor (e.g. 0-adjacent values in a custom chain making the division inflate the result).","commonSituations":"Passing a wrongly-scaled gas price (unit confusion, e.g. sending the full-token amount instead of per-gas amount); custom chains with a broken gas_price_factor consensus parameter.","solutions":["Re-check the gas price you send: use the value from the node's estimateGasPrice, not a hand-scaled constant","Lower the tx's gas ceiling (script gas limit, witness/data usage) so gas x price fits u64","If you operate the chain, verify consensus parameter gas_price_factor is set correctly"],"exampleFix":"// before\nawait client.assembleTx(txBytes, { requiredBalances, gasPrice: 1_000_000_000_000n }); // wrong scale\n\n// after\nconst { gasPrice } = await client.queryEstimateGasPrice(blockHorizon);\nawait client.assembleTx(txBytes, { requiredBalances /* node-derived gas price */ });","handlingStrategy":"validation","validationCode":"// client-side mirror of gas_to_fee: fee = gas * gasPrice / gasPriceFactor\nconst fee = (BigInt(finalGas) * gasPrice) / BigInt(gasPriceFactor);\nif (fee > 2n ** 64n - 1n) throw new Error(`fee ${fee} overflows u64; lower gas price or gas limit`);","typeGuard":null,"tryCatchPattern":"catch (e) { if (/final fee is too big to fit into/.test(e.message)) { /* use node-reported gas price, reduce script gas limit / tip */ } else throw e; }","preventionTips":["Always take gas price from the node's estimation endpoint instead of hardcoding","Double-check unit scaling of any manual gas price (per-gas, not total)","Chain operators: verify gas_price_factor in consensus parameters after upgrades"],"tags":["fee","gas-price","overflow","consensus","assemble-tx"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}