{"record":{"id":"704fac1caa56204e","repo":"FuelLabs/fuel-core","slug":"filling-required-balances-occupies-a-number-of-inp","errorCode":null,"errorMessage":"Filling required balances occupies a number of inputs more than can fit into the transaction","messagePattern":"Filling required balances occupies a number of inputs more than can fit into the transaction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/schema/tx/assemble_tx.rs","lineNumber":408,"sourceCode":"        }\n\n        self.estimate_script_if_possible().await?;\n\n        self.remove_unused_variable_outputs();\n\n        self = self.cover_fee().await?;\n\n        self.adjust_witness_limit();\n\n        Ok(self.tx)\n    }\n\n    fn remaining_input_slots(&self) -> anyhow::Result<u16> {\n        let max_input = self.arguments.consensus_parameters.tx_params().max_inputs();\n        let used_inputs = u16::try_from(self.tx.inputs().len()).unwrap_or(u16::MAX);\n\n        if used_inputs > max_input {\n            return Err(anyhow::anyhow!(\n                \"Filling required balances occupies a number \\\n                    of inputs more than can fit into the transaction\"\n            ));\n        }\n\n        Ok(max_input.saturating_sub(used_inputs))\n    }\n\n    async fn add_inputs_and_witnesses_and_changes(&mut self) -> anyhow::Result<()> {\n        let required_balance = core::mem::take(&mut self.arguments.required_balances);\n\n        for required_balance in required_balance {\n            let remaining_input_slots = self.remaining_input_slots()?;\n\n            let asset_id = required_balance.asset_id;\n            let amount = required_balance.amount;\n            let owner = required_balance.account.owner();\n","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/schema/tx/assemble_tx.rs#L390-L426","documentation":"remaining_input_slots() computes how many free input slots the tx still has (max_inputs minus current inputs) and errors if the tx is already over max_inputs. It fires during assembly when the inputs added to satisfy required balances and fee have consumed more slots than the consensus parameter allows.","triggerScenarios":"requiredBalances needing many coins (dusty wallets) so that, added to the tx's existing inputs, the total exceeds tx_params.max_inputs; each fee-covering iteration calls remaining_input_slots and re-checks the budget.","commonSituations":"Accounts with many small UTXOs; requiring many distinct assets/accounts in one transaction; custom chains with lowered max_inputs.","solutions":["Consolidate the wallet's UTXOs (sweep dust into one coin) before assembling","Reduce the number of requiredBalances entries or the tx's pre-existing inputs","If you operate the chain, raise max_inputs via consensus parameters"],"exampleFix":"// before\nawait client.assembleTx(txBytes, { requiredBalances: allAssets }); // wallet has 240 dust coins, tx has 20 inputs\n\n// after\nawait consolidateUtxos(client, feeAccount); // one coin per asset\nawait client.assembleTx(txBytes, { requiredBalances: allAssets });","handlingStrategy":"validation","validationCode":"const info = await client.request(gql`{ chain { consensusParameters { txParameters { maxInputs } } } }`);\nconst maxInputs = Number(info.chain.consensusParameters.txParameters.maxInputs);\nconst tx = Transaction.fromBytes(txBytes);\n// each required balance may need >= 1 coin input\nif (tx.inputs.length + requiredBalances.length > maxInputs) {\n  throw new Error(`input budget exceeded: ${tx.inputs.length} + ${requiredBalances.length} > ${maxInputs}`);\n}","typeGuard":null,"tryCatchPattern":"catch (e) { if (/occupies a number of inputs more than can fit/.test(e.message)) { /* consolidate UTXOs / split tx, then retry */ } else throw e; }","preventionTips":["Track per-account UTXO counts and consolidate when they grow","Keep requiredBalances small per transaction","Remember the tx's own inputs count against the same budget"],"tags":["transaction","consensus","inputs","utxo","assemble-tx"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}