How to consolidate
- Change the selection strategy for the vault account and asset from Adaptive to Ascending (ASC), which uses the smallest UTXOs first. Adaptive Selection, the default, does not necessarily favor small UTXOs. You can do this in the Fireblocks Console (Settings > General > UTXO selection strategy) or with the UTXO selection configuration API (
PUT /utxo_management/{vaultAccountId}/{assetId}/selection_config). - Call Get max spendable amount in a transaction for the vault account and asset. With ASC, it returns the sum of the smallest available UTXOs, up to the input limit and before the network fee.
- Create a transaction for that amount with
treatAsGrossAmountset totrue, and send it to your own vault account: the permanent deposit address of a vault account you own, which can be the source vault account. The fee is deducted from the amount, so the selected inputs cover it and the transaction has one output and no change. - Repeat steps 2 and 3 until the wallet has few enough UTXOs. Wait until the previous transaction reaches
PENDING_SIGNATUREor a later status, such asBROADCASTINGorCONFIRMING, because it has selected its inputs by then. Do not send several consolidation transactions at once, because max spendable returns the same UTXOs until the first transaction selects them. - When you finish, change the strategy back to Adaptive.
Fees
The network fee is paid from the funds being consolidated, so consolidate when fees are low. A native SegWit input adds about 68 vbytes, so a transaction that spends 250 inputs is about 17,000 vbytes: roughly 17,000 satoshis at 1 sat/vB and 85,000 satoshis at 5 sat/vB. The smallest UTXOs can be worth less than the fee needed to spend them. If the quoted amount is smaller than the fee, the transaction fails. In that case, wait for lower fees, or consolidate only UTXOs above a minimum amount using the filters described in Select UTXOs for a transaction. Use the same filters in both calls. Set them as query parameters on Get max spendable amount (for example,minAmount), and pass them in utxoSelectionParams.filters when you create the transaction. Selection ignores filters that the transaction request leaves out, so it would pick the smallest UTXOs and the amount would no longer match.