Include UTXO containing both ADA and assets in a transaction sending ADA only

Hello,

I am trying to understand how UTXOs work.

Can I use a UTXO that contains both ADA and asset for a transaction just sending ADA only? Or am I forced to use the UTXOs that only contain ADA?

Many thanks!

Everything that is on UTxOs – ADA and native tolens – going into a transaction has to be put into an output going out of that transaction.

If there are enough ADA, you can put them into a change output going back to your own wallet. Most transactions will have such a change output, since you very seldomly have a UTxO with exactly the value you want to send out.

So, UTxOs with native tokens can go into a transaction that only sends pure ADA to someone else, but the native tokens will go back to you.

1 Like

Many thanks for the information @HeptaSean.

I currently tested a transaction sending only ADA with a UTXO containing both ADA and a single asset and received this error

{"error": "Bad Request", "message": "\"transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 995235902 (fromList [(PolicyID {policyID = ScriptHash \\\"6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7\\\"},fromList [(,2)])])) (Value 995235902 (fromList [])))))])\"", "status_code": 400}

Not really understand why.

As said here and on Telegram, you have to tell it, to which output the native token should be sent to. You cannot just let it disappear.

This means, if the UTXO has multiple assets and I only want to send ADA, I have to add the outputs for all of the assets of the UTXO?

In any transaction you have one or more inputs and one or more outputs.
Because usually you don’t have an input UTxO which covers exactly the amount of ADA you want to send plus the fees, you also need to have a “change” output, which goes back to your wallet. And the “change” output should also be at least 1 ADA, or about 1.4 - 1.5 ADA if it also contains other tokens (depending on the tokens name).
If you are using an input UTxO which contains ADA plus Tokens and you want to send only ADA, you also need to create an output UTxO with the tokens and the rest of ADA which goes back to your wallet (or whatever address you want to send it to).

2 Likes

Many thanks

1 Like

I’ll take a shot at giving a clearer explanation.

Utxos have a Value, made up of Lovelace (Ada) aka “coin” and optional “multi-assets”. The multi-assets part of a utxo value represents any other tokens (identified by their policyId, name and quantity).

As others have said, the sum of the input Values of a transaction must match the sum of output Values plus tx fee.

It is possible to only send lovelace from a utxo that also contains multi-assets, and return the multi-assets to your address as change.

There is a caveat however. A Utxo can not contain only multi-assets, but must also contain a minimum amount of lovelace. This minimum amount depends on the total byte size of all the token’s policy ids, names and quantities and the “coinsPerUtxoWord” (being renamed to coinsPerUTxoByte in the Babbage era). More info here: https://docs.cardano.org/native-tokens/minimum-ada-value-requirement

You can calculate the exact amount of required lovelace that a utxo must contain for a specific set of tokens using cardano-cli transaction calculate-min-required-utxo.

So, you must make sure that your transaction output that will return the tokens as change to your address, will contain at least the minimum required amount of lovelace for your set of tokens.

1 Like

Thanks for the information!