{"record":{"id":"3d64bcd81b743da8","repo":"FuelLabs/fuels-ts","slug":"no-coins-to-consolidate","errorCode":"NO_COINS_TO_CONSOLIDATE","errorMessage":"No coins to consolidate.","messagePattern":"No coins to consolidate\\.","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"warning","filePath":"packages/account/src/account.ts","lineNumber":1275,"sourceCode":"\n      return await assembleTx();\n    }\n  }\n\n  /** @hidden * */\n  private validateTransferAmount(amount: BigNumberish) {\n    if (bn(amount).lte(0)) {\n      throw new FuelError(\n        ErrorCode.INVALID_TRANSFER_AMOUNT,\n        'Transfer amount must be a positive number.'\n      );\n    }\n  }\n\n  /** @hidden * */\n  private validateConsolidationTxsCoins(coins: Coin[], assetId: string) {\n    if (coins.length <= 1) {\n      throw new FuelError(ErrorCode.NO_COINS_TO_CONSOLIDATE, 'No coins to consolidate.');\n    }\n\n    if (!coins.every((c) => c.assetId === assetId)) {\n      throw new FuelError(\n        ErrorCode.COINS_ASSET_ID_MISMATCH,\n        'All coins to consolidate must be from the same asset id.'\n      );\n    }\n  }\n\n  /** @hidden * */\n  private async setTransactionStateForConnectors(params: {\n    transactionRequest: TransactionRequest;\n    connectorOptions: AccountSendTxParams;\n  }): Promise<{\n    transactionRequest: TransactionRequest;\n    connectorsSendTxParams: FuelConnectorSendTxParams;\n  }> {","sourceCodeStart":1257,"sourceCodeEnd":1293,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/account.ts#L1257-L1293","documentation":"Thrown by validateConsolidationTxsCoins when the supplied coin array has 0 or 1 entries. Consolidation merges many UTXOs into fewer ones; with a single coin there is nothing to consolidate, so the SDK aborts rather than build a no-op transaction that still costs gas. Called from assembleBaseAssetConsolidationTxs and assembleNonBaseAssetConsolidationTxs.","triggerScenarios":"Calling account.consolidateCoins({ assetId }) (or the assemble*ConsolidationTxs methods) when the account has only one UTXO (or none) for that asset, or passing a pre-fetched coins array of length <= 1.","commonSituations":"Consolidating on a fresh or recently-swept wallet that has one UTXO left, calling consolidate repeatedly until only one UTXO remains, or filtering coins down to a single element before consolidation.","solutions":["Check the UTXO count for the asset before consolidating and skip if <= 1: const coins = await provider.getCoins(account, assetId); if (coins.length > 1) await account.consolidateCoins({ assetId });.","Wrap the call in a try/catch for NO_COINS_TO_CONSOLIDATE and treat it as an expected no-op.","Re-fetch coins right before consolidation rather than trusting a stale count."],"exampleFix":"// before\nawait account.consolidateCoins({ assetId });\n\n// after\nconst { coins } = await provider.getCoins(account.address, assetId);\nif (coins.length > 1) {\n  await account.consolidateCoins({ assetId });\n}","handlingStrategy":"validation","validationCode":"// Only consolidate when there is more than one UTXO\nconst { coins } = await provider.getCoins(account.address, assetId);\nif (coins.length > 1) {\n  await account.consolidateCoins({ assetId });\n}","typeGuard":"function hasMultipleCoins(coins: Coin[]): boolean {\n  return coins.length > 1;\n}","tryCatchPattern":"try {\n  await account.consolidateCoins({ assetId });\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.NO_COINS_TO_CONSOLIDATE) {\n    // expected no-op; nothing to consolidate\n  } else throw e;\n}","preventionTips":["Pre-fetch the UTXO count for the asset and skip consolidation when <= 1.","Treat NO_COINS_TO_CONSOLIDATE as an expected condition, not a fatal error.","Avoid calling consolidate in a tight loop that drives the UTXO set to one."],"tags":["consolidation","utxo","no-op","account"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}