0

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

2 Answers 2

3

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

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 <TxHash>#<TxIx> \
--tx-out <payment.addr>+<change> \
--tx-out <destinationAddress>+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 <TxHash>#<TxIx> \
--tx-in <TxHash>#<TxIx> \
--tx-in <TxHash>#<TxIx> \
--tx-out <payment.addr>+<totalchange> \
--tx-out <destinationAddress>+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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.