{"record":{"id":"70090ae40647ade3","repo":"FuelLabs/fuels-ts","slug":"max-inputs-exceeded","errorCode":"MAX_INPUTS_EXCEEDED","errorMessage":"The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}","messagePattern":"The transaction exceeds the maximum allowed number of inputs\\. Tx inputs: (.+?), max inputs: (.+?)","errorType":"validation","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/account/src/providers/provider.ts","lineNumber":1107,"sourceCode":"  #cacheInputs(inputs: TransactionRequestInput[], transactionId: string): void {\n    if (!this.cache) {\n      return;\n    }\n\n    this.cache.set(transactionId, inputs);\n  }\n\n  /**\n   * @hidden\n   */\n  async validateTransaction(tx: TransactionRequest) {\n    const {\n      consensusParameters: {\n        txParameters: { maxInputs, maxOutputs },\n      },\n    } = await this.getChain();\n    if (bn(tx.inputs.length).gt(maxInputs)) {\n      throw new FuelError(\n        ErrorCode.MAX_INPUTS_EXCEEDED,\n        `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`\n      );\n    }\n\n    if (bn(tx.outputs.length).gt(maxOutputs)) {\n      throw new FuelError(\n        ErrorCode.MAX_OUTPUTS_EXCEEDED,\n        `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`\n      );\n    }\n  }\n\n  /**\n   * Submits a transaction to the chain to be executed.\n   *\n   * If the transaction is missing any dependencies,\n   * the transaction will be mutated and those dependencies will be added.","sourceCodeStart":1089,"sourceCodeEnd":1125,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/account/src/providers/provider.ts#L1089-L1125","documentation":"Thrown by Provider.validateTransaction when the number of inputs on a transaction request exceeds the chain's consensus parameter txParameters.maxInputs. The chain will reject such a transaction, so the SDK fails during validation. The threshold comes from getChain() consensus parameters and may differ per network.","triggerScenarios":"Calling provider.validateTransaction(tx) (or a send path that invokes it) with a transactionRequest whose inputs array is longer than maxInputs; batching many UTXOs/messages into one tx; not consolidating resources before a large transfer.","commonSituations":"Account has many small UTXOs and a transfer gathers them all; merging message inputs across epochs; an airdrop/merge script that sweeps dozens of coins; maxInputs lowered by a consensus parameter change on the network.","solutions":["Reduce the number of inputs: combine UTXOs first via a consolidation transaction before the main tx.","Use the account's resource-fetching with larger per-resource amounts to need fewer inputs.","Check (await provider.getChain()).consensusParameters.txParameters.maxInputs and split the tx if needed.","If merging many messages, do it across multiple transactions."],"exampleFix":"// before — single tx with too many inputs\nconst resources = await account.getResourcesToSpend([...]);\nconst tx = new ScriptTransactionRequest({});\ntx.addResources(resources); // may exceed maxInputs\n\n// after — consolidate first, then spend\n// 1) run a merge tx to coalesce small UTXOs into fewer larger ones\n// 2) re-fetch resources (fewer inputs) and build the real tx\nconst { maxInputs } = (await provider.getChain()).consensusParameters.txParameters;\nif (resources.length > maxInputs.toNumber()) {\n  throw new Error(`Too many inputs (${resources.length} > ${maxInputs}); consolidate first.`);\n}","handlingStrategy":"validation","validationCode":"async function assertInputsUnderLimit(provider, tx) {\n  const { maxInputs } = (await provider.getChain()).consensusParameters.txParameters;\n  if (tx.inputs.length > maxInputs.toNumber()) {\n    throw new Error(`Too many inputs (${tx.inputs.length} > ${maxInputs}); consolidate first.`);\n  }\n}","typeGuard":"function inputsFitLimit(inputCount: number, maxInputs: { toNumber(): number }): boolean {\n  return inputCount <= maxInputs.toNumber();\n}","tryCatchPattern":"import { FuelError, ErrorCode } from '@fuel-ts/errors';\ntry {\n  await provider.validateTransaction(tx);\n} catch (e) {\n  if (e instanceof FuelError && e.code === ErrorCode.MAX_INPUTS_EXCEEDED) {\n    // run a consolidation tx first, then retry with fewer inputs\n  }\n  throw e;\n}","preventionTips":["Consolidate small UTXOs periodically to keep input counts low.","Read maxInputs from consensus parameters before building large txs.","Prefer fewer, larger resources when fetching resources to spend."],"tags":["transaction","consensus-params","utxo","validation"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}