{"record":{"id":"26c9af9aab902cda","repo":"FuelLabs/fuels-ts","slug":"max-fee-too-low","errorCode":"MAX_FEE_TOO_LOW","errorMessage":"Max fee '${setMaxFee}' is lower than the required: '${requiredMaxFee}'.","messagePattern":"Max fee '(.+?)' is lower than the required: '(.+?)'\\.","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/providers/assemble-tx-helpers.ts","lineNumber":84,"sourceCode":"  const maxFeeSpecified = isDefined(setMaxFee);\n  const isScriptTx = transactionRequest.type === TransactionType.Script;\n\n  if (gasLimitSpecified && isScriptTx) {\n    const requiredGasLimit = transactionRequest.gasLimit;\n    if (bn(setGasLimit).lt(bn(requiredGasLimit))) {\n      throw new FuelError(\n        ErrorCode.GAS_LIMIT_TOO_LOW,\n        `Gas limit '${setGasLimit}' is lower than the required: '${requiredGasLimit}'.`\n      );\n    }\n\n    transactionRequest.gasLimit = bn(setGasLimit);\n  }\n\n  if (maxFeeSpecified) {\n    const requiredMaxFee = transactionRequest.maxFee;\n    if (bn(setMaxFee).lt(requiredMaxFee)) {\n      throw new FuelError(\n        ErrorCode.MAX_FEE_TOO_LOW,\n        `Max fee '${setMaxFee}' is lower than the required: '${requiredMaxFee}'.`\n      );\n    }\n\n    transactionRequest.maxFee = bn(setMaxFee);\n  }\n\n  if (gasLimitSpecified && !maxFeeSpecified) {\n    const { maxFee: feeForGasPrice } = await provider.estimateTxGasAndFee({\n      transactionRequest,\n      gasPrice,\n    });\n\n    transactionRequest.maxFee = feeForGasPrice;\n  }\n\n  return transactionRequest;","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/providers/assemble-tx-helpers.ts#L66-L102","documentation":"Thrown by setAndValidateGasAndFeeForAssembledTx when the caller-supplied setMaxFee is less than transactionRequest.maxFee (the minimum required max fee computed from gas limit, gas price, and byte size). maxFee is the user-declared ceiling the chain enforces; setting it below the required amount guarantees the tx would be rejected, so the SDK fails fast.","triggerScenarios":"Passing setMaxFee below the estimated max fee when assembling/sending a transaction; setting a fixed low fee after gas-price spikes; computing max fee without including the byte/gas-price component.","commonSituations":"Hardcoding maxFee from a previous network state; gas price rose between estimation and submission; migrating to an SDK version that began enforcing the floor; underestimating fee for a large script tx.","solutions":["Omit setMaxFee so the SDK derives it from the current estimate.","Read transactionRequest.maxFee after estimation and pass setMaxFee >= it.","Re-estimate with provider.estimateTxGasAndFee before specifying setMaxFee.","Add a margin to absorb gas-price variance: bn(requiredMaxFee).mul(12).div(10)."],"exampleFix":"// before\nawait account.assembleTx({ transactionRequest, setMaxFee: 1 });\n\n// after\nconst { maxFee } = await provider.estimateTxGasAndFee({ transactionRequest, gasPrice });\nawait account.assembleTx({\n  transactionRequest,\n  setMaxFee: bn(maxFee).mul(12).div(10), // >= required\n});","handlingStrategy":"validation","validationCode":"import { bn } from '@fuel-ts/math';\nfunction validateMaxFee(setMaxFee, requiredMaxFee) {\n  if (bn(setMaxFee).lt(requiredMaxFee)) {\n    throw new Error(`Max fee must be >= ${requiredMaxFee.toString()}`);\n  }\n}","typeGuard":"function maxFeeIsSufficient(setMaxFee, requiredMaxFee): boolean {\n  return bn(setMaxFee).gte(bn(requiredMaxFee));\n}","tryCatchPattern":"import { FuelError, ErrorCode } from '@fuel-ts/errors';\ntry {\n  await account.assembleTx({ transactionRequest, setMaxFee });\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.MAX_FEE_TOO_LOW) {\n    // bump setMaxFee to >= requiredMaxFee or omit it\n  }\n  throw e;\n}","preventionTips":["Re-estimate fees right before submission (gas price changes).","Add a margin to maxFee to absorb gas-price variance.","Prefer omitting setMaxFee unless you need a hard ceiling."],"tags":["fee","transaction","validation","gas"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}