<p>In your build command specify multiple txins and one txout with the sum of all the Ada and tokens from spent utxos.</p>

CC BY-SA 4.0
2022-03-02T04:39:34.393Z
2022-03-02T04:39:34.393Z
Samuel Leathers
<p>I wanted to elaborate on Samuel's answer to be more details. Let's say you are building a transaction that looks like the following:</p>
<pre><code>cardano-cli transaction build-raw \
--tx-in &lt;TxHash&gt;#&lt;TxIx&gt; \
--tx-out &lt;payment.addr&gt;+&lt;change&gt; \
--tx-out &lt;destinationAddress&gt;+0 \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee 0 \
--out-file tx.tmp
</code></pre>
<p>All you have to do is create more --tx-in options. Make sure you calculate the total ada in all --tx-in options to correctly calculate the change output for the single tx-out. Something of the pattern below would work using 3 --tx-in arguments.</p>
<pre><code>cardano-cli transaction build-raw \
--tx-in &lt;TxHash&gt;#&lt;TxIx&gt; \
--tx-in &lt;TxHash&gt;#&lt;TxIx&gt; \
--tx-in &lt;TxHash&gt;#&lt;TxIx&gt; \
--tx-out &lt;payment.addr&gt;+&lt;totalchange&gt; \
--tx-out &lt;destinationAddress&gt;+0 \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee 0 \
--out-file tx.tmp
</code></pre>
<p>Lastly, remember that the utxo must balance out to zero so
all the utxos with ada your are using must equal the fee plus how much ada you are sending plus how much change you have in your one combined utxo left over</p>

CC BY-SA 4.0
2022-03-03T08:24:37.003Z
2022-03-05T06:29:35.753Z
2022-03-05T06:29:35.753Z
christobear
<p>I have several utxos in my cardano wallet address created via the cardano-cli that have 1-4 ADA each. Some utxos have an NFT associated with them. Is there a way to spend the rest of several utxos in one transaction? Is there a way to combine several utxos?</p>
<p>I created the wallet using the cli using the following commands:</p>
<pre><code>cardano-cli address key-gen --verification-key-file payment.vkey --signing-key-file payment.skey

cardano-cli address build --payment-verification-key-file payment.vkey --out-file payment.addr --mainnet
</code></pre>

<cardano-cli><cardano-node><utxo>
How to combine or spend the rest of utxos
# How to combine or spend the rest of utxos

(Asked by: username_0 on 2022-03-02)

I have several utxos in my cardano wallet address created via the cardano-cli that have 1-4 ADA each. Some utxos have an NFT associated with them. Is there a way to spend the rest of several utxos in one transaction? Is there a way to combine several utxos?
I created the wallet using the cli using the following commands:
cardano-cli address key-gen --verification-key-file payment.vkey --signing-key-file payment.skey

cardano-cli address build --payment-verification-key-file payment.vkey --out-file payment.addr --mainnet

**Tags:** cardano-cli, cardano-node, utxo

---

## 2 answers

### Answer by username_1 on 2022-03-02. Score: 3

In your build command specify multiple txins and one txout with the sum of all the Ada and tokens from spent utxos.


---

### Answer by username_2 on 2022-03-03. Score: 3

I wanted to elaborate on Samuel's answer to be more details. Let's say you are building a transaction that looks like the following:
cardano-cli transaction build-raw \
--tx-in # \
--tx-out + \
--tx-out +0 \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee 0 \
--out-file tx.tmp

All you have to do is create more --tx-in options. Make sure you calculate the total ada in all --tx-in options to correctly calculate the change output for the single tx-out. Something of the pattern below would work using 3 --tx-in arguments.
cardano-cli transaction build-raw \
--tx-in # \
--tx-in # \
--tx-in # \
--tx-out + \
--tx-out +0 \
--invalid-hereafter $(( ${currentSlot} + 10000)) \
--fee 0 \
--out-file tx.tmp

Lastly, remember that the utxo must balance out to zero so
all the utxos with ada your are using must equal the fee plus how much ada you are sending plus how much change you have in your one combined utxo left over


---

