{"record":{"id":"a44652fc9d89e88b","repo":"FuelLabs/fuels-ts","slug":"insufficient-funds-a44652","errorCode":"INSUFFICIENT_FUNDS","errorMessage":"Insufficient funds to consolidate.\n\tAsset ID: ${baseAssetId}\n\tOwner: ${account.address.toB256()}","messagePattern":"Insufficient funds to consolidate\\.\n\tAsset ID: (.+?)\n\tOwner: (.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/utils/consolidate-coins.ts","lineNumber":145,"sourceCode":"\n  let funding: Coin[] = [];\n  let dust: Coin[] = [];\n\n  // We get the largest coin/s for funding purposes\n  if (isBaseAsset) {\n    const coins = await getAllCoins(account, baseAssetId).then(sortCoins);\n    funding = coins.slice(0, numberOfFundingCoins);\n    dust = coins.slice(numberOfFundingCoins);\n  } else {\n    funding = await getAllCoins(account, baseAssetId)\n      .then(sortCoins)\n      .then((coins) => coins.slice(0, numberOfFundingCoins));\n    dust = await getAllCoins(account, assetId).then(({ coins }) => coins);\n  }\n\n  // There a better way of detecting whether the account has enough funds to consolidate\n  if (funding.length === 0) {\n    throw new FuelError(\n      ErrorCode.INSUFFICIENT_FUNDS,\n      `Insufficient funds to consolidate.\\n\\tAsset ID: ${baseAssetId}\\n\\tOwner: ${account.address.toB256()}`\n    );\n  }\n\n  const batches = [\n    ...splitEvery(batchSize, funding),\n    // We leave one coin for the funding coin\n    ...splitEvery(batchSize - 1, dust),\n  ];\n\n  const txs: ScriptTransactionRequest[] = batches.map((batch) => {\n    const request = new ScriptTransactionRequest({\n      scriptData: '0x',\n    });\n\n    // Add our dust coins as inputs\n    request.addResources(batch);","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/utils/consolidate-coins.ts#L127-L163","documentation":"Thrown by consolidateCoins() when, after fetching and sorting all base-asset coins for the account, the 'funding' array is empty. With no funding coins, the account cannot pay gas for even the first consolidation transaction. The message echoes the base asset id and owner address for diagnosis.","triggerScenarios":"Calling account.consolidateCoins / startConsolidation on an account that holds zero coins of the base asset (the fee-paying asset), regardless of whether it holds other assets. The check is funding.length === 0 after getAllCoins(account, baseAssetId).","commonSituations":"Fresh account never funded with base asset; account drained by prior transactions; wrong account selected for consolidation; baseAssetId mismatch between provider config and the asset the account actually holds; test that funds only non-base assets.","solutions":["Fund the account with base-asset coins (e.g. via a faucet or transfer) before consolidating.","Verify account.address matches the account that owns the coins you expect.","Confirm provider.getBaseAssetId() returns the asset id the account is funded with.","If consolidating a non-base asset, the account still needs base-asset coins to pay gas."],"exampleFix":"// before\nawait account.consolidateCoins({ assetId }); // account has no base asset\n// after\nawait faucet.fund(account.address, baseAssetId, 1_000_000);\nawait account.consolidateCoins({ assetId });","handlingStrategy":"validation","validationCode":"const baseCoins = await account.getCoins(baseAssetId);\nif (baseCoins.coins.length === 0) {\n  throw new Error('Account has no base-asset coins; fund it before consolidating.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await account.consolidateCoins({ assetId });\n} catch (err) {\n  if (err instanceof FuelError && err.code === ErrorCode.INSUFFICIENT_FUNDS) {\n    await faucet.fund(account.address, baseAssetId, minBalance);\n    await account.consolidateCoins({ assetId });\n  } else throw err;\n}","preventionTips":["Pre-fund accounts with base asset before any consolidation or tx submission.","Verify provider.getBaseAssetId() matches the asset the account holds.","Check coin balances via account.getCoins before consolidating."],"tags":["consolidation","insufficient-funds","utxo","account","base-asset"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}