{"record":{"id":"5d18a4816bbc4912","repo":"FuelLabs/fuels-ts","slug":"insufficient-funds","errorCode":"INSUFFICIENT_FUNDS","errorMessage":"The account ${this.address} does not have enough base asset funds to cover the transaction execution.","messagePattern":"The account (.+?) does not have enough base asset funds to cover the transaction execution\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/account.ts","lineNumber":406,"sourceCode":"      const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);\n\n      if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {\n        needsToBeFunded = false;\n      } else {\n        missingQuantities = [\n          {\n            amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),\n            assetId: baseAssetId,\n          },\n        ];\n      }\n\n      fundingAttempts += 1;\n    }\n\n    // If the transaction still needs to be funded after the maximum number of attempts\n    if (needsToBeFunded) {\n      throw new FuelError(\n        ErrorCode.INSUFFICIENT_FUNDS,\n        `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`\n      );\n    }\n\n    request.updateState(chainId, 'funded', transactionSummary);\n\n    await this.provider.validateTransaction(request);\n\n    request.updatePredicateGasUsed(estimatedPredicates);\n\n    const requestToReestimate = clone(request);\n    if (addedSignatures) {\n      Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());\n    }\n\n    if (!updateMaxFee) {\n      return request;","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/account.ts#L388-L424","documentation":"After MAX_FUNDING_ATTEMPTS (5) rounds of fetching resources and re-estimating the fee, the account still cannot cover the base-asset requirement (transfer amount + gas/fee). The loop bails out and surfaces INSUFFICIENT_FUNDS so callers know the failure is a balance problem, not a network or encoding problem.","triggerScenarios":"Calling account.fund / sendTransaction / transfer when the account's base-asset balance plus gathered UTXOs is less than amount + maxFee; fee spikes between attempts; too few UTXOs and consolidation disabled; dust-only balances.","commonSituations":"Insufficient funds in the wallet; gas price spike on a busy network; many small UTXOs hitting consolidation limits; wrong account used for the transfer; base asset ID mismatch.","solutions":["Check the base-asset balance before submitting: await account.getBalance() and compare against amount + estimated fee.","Top up the account with base asset and retry.","Consolidate dust UTXOs (account.cons ConsolidateCoins) to increase spendable UTXO coverage.","Raise the gas limit / max-fee policy only if the issue is fee underestimation, then retry."],"exampleFix":"// before\nconst tx = await account.transfer(target, 1_000_000);\n\n// after\nconst baseAssetId = await account.provider.getBaseAssetId();\nconst bal = (await account.getBalances()).find(b => b.assetId === baseAssetId)?.amount ?? 0n;\nif (bal < 1_000_000n + estimatedFee) {\n  throw new Error(`need more base asset; have ${bal}`);\n}\nconst tx = await account.transfer(target, 1_000_000);","handlingStrategy":"validation","validationCode":"async function assertSufficientBaseAsset(\n  account: Account,\n  amount: bigint,\n  estimatedFee: bigint\n) {\n  const baseAssetId = await account.provider.getBaseAssetId();\n  const bal = (await account.getBalances()).find(b => b.assetId === baseAssetId)?.amount ?? 0n;\n  if (bal < amount + estimatedFee) {\n    throw new Error(`Insufficient base asset: have ${bal}, need ${amount + estimatedFee}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await account.transfer(target, amount);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.INSUFFICIENT_FUNDS) {\n    // top up wallet or reduce amount, then retry once\n  }\n  throw e;\n}","preventionTips":["Pre-check the base-asset balance against amount + estimated fee before submitting.","Consolidate dust UTXOs before high-value transfers.","Fund test accounts from a faucet before running transactions.","Watch gas-price spikes on congested networks and retry when fee falls."],"tags":["account","insufficient-funds","transaction","balance","gas"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}