MINT token with more than 2 txout/txin + calculate min-ADA


I am experimenting with tokens.
Is it posible to mint a token with minADA + fee paid by address1 and the token delivered to address2.
If possible what the script should look like ?

1 Like

Yes. I did so in my last project to avoid the mess of having funds and tokens on the same address. In the transaction you would have on tx-in that is your funding address, and two tx-out that is the unused funds going back to the funding address and other the tx-out that has the token(s) and their needed min-ada-value.
This way makes it a lot easier to manage the accounts :slight_smile:


So based on your explaination the script should be like:

cardano-cli transaction build-raw
–tx-out $(cat key/payment.addr)+${txOut}
–tx-out $destinationAddress+${minADA}+"$tokenamount $policyid.$tokenname"
–mint="$tokenamount $policyid.$tokenname"
–metadata-json-file NFT/metadata.json
–invalid-hereafter $(( ${currentSlot} + 10000))
–fee 0
–out-file tx.tmp

Or would you mind share your script ?


This is how mine looks like:

cardano-cli transaction build-raw
–fee 0
–invalid-hereafter {slotNumber}
–tx-in {TxHash}#{TxIx}
–tx-out $(cat payment.addr)+0
–tx-out {alternative address}+{MinADA}+“1 {policyid}.{NFTName1} + 1 {policyid}.{NFTName2}”
–mint=“1 {policyid}.{NFTName1} + 1 {policyid}.{NFTName2}”
–metadata-json-file metadata.json
–out-file tx.raw


Alright, thanks guys.
I tried those on testnet and successfully sent it to alternate addresss.

Next question,
How do you deal with minADA ?
Currently to make sure there is no problem with this transaction so i put 10 ADA there.
Do you have a detail script to calculate everyting on terminal ?

I found this documentation, but honestly i am new to this linux thing and still learning by myself on the line, thats why still confuse and have no idea how to put it on script :sweat_smile:
Much appreciated if there a sample…

1 Like

The minimum to send a token is 1500000 Lovelace ie 1.5ADA.

In my example above were I am sending two tokens, the minimum for the token address would be 3000000 Lovelace ie 3 ADA.
The rest minus the fee I would be sending them back to the payment address.

1 Like

Thank you for the insight,
But i would like to calculate as minimum as posible just like daedalus did when you tried to sent an asset it will give information the minimum ADA needed.

EDIT: Apologies, the previous version of the post was based on coinSize = 2, but the current network is still using coinSize = 0. The table below is valid for the network as of this posting date.

If there is just one asset in the --tx-out, one can use the following table to find the min-ADA. If there are multiple tokens, then one can use an online min-ADA calculator.

Length in Bytes of Asset Name min-ADA
up to 8 1.444443
9 to 16 1.481480
17 to 24 1.518517
24 to 32 1.555554

If the asset name includes unicode characters, then its length in bytes might be a little larger than the number of characters it contains.

If one wants to calculate min-ADA in a bash shell script when there is only one token, then one can use the formula $(( ((${#NAME} - 1) / 8) * 37037 + 1444443)). For example:

MINLOVELACE=$(( ((${#NAME} - 1) / 8) * 37037 + 1444443 ))

# prints 1481480
1 Like

Wonderfull, this is what i’m looking for.
Thanks @bwbush
Currently i just need to put 1 token on every txout.
Another question,
I’ve seen your min-ADA calculator, but still confuse to use it, is there any detail explaination each attributes on parameters, properties and results ?
Would be great if there is sample of use case to implement those.

I did that in bash to get exact value to use at


sumAssetNameLengths=$(cat cnftname | wc -c)


adaOnlyUTxOSize=$(( $utxoEntrySizeWithoutVal + $coinSize ))

roundupBytesToWords=$(bc <<< "scale=0; ( $numAssets*12 + $sumAssetNameLengths + $numPIDs*$pidSize + 7 ) / 8")

tokenBundleSize=$(( 6 + $roundupBytesToWords ))

minAda=$(( $(bc <<< "scale=0; $THEminUTxOValue / $adaOnlyUTxOSize") * ( $utxoEntrySizeWithoutVal + $tokenBundleSize ) ))

Hope it helps :slight_smile:


I added documentation for the parameters and three example calculations to the online min-ADA calculator. Hopefully, it is easier to use now. I appreciate your feedback!


This script really helps.
Much appreciated you shared this here, hope it will helps the community.

1 Like

Thank you, that makes us easier to understand and use it :slight_smile:
Keep up the wonderful work. Really appreciate it.


I’ve variant on this question I’ve been experimenting with tokens also.

I want to understand is it possible to MINT with two or more inputs --tx-ins so the opposite problem with a twist.

The scenario is you may not have enough lovelace in an individual UTXO but between the two there is sufficient. I’ve tried and failed so I’m curious to the fundamentals of UTXOs and what is possible.

In my frustration, I tried to simplified the problem to send two UTXO’s to another address, without minting , to combine them into a single UTXO minus the fees , but I’ve also failed here.

So my second question when you have multiple UTXO’s that you want to combine as inputs and there is NO change, so you want to completely spend everything minus fees. How does that work ? Do you have to commit a transaction and assign Zero as change, or is this automatic or some flag has to be set. I can’t get this to work have consistent errors of ValueNotConservedUTxO. Hence, I need to understand whats fundamentally possible what do you do with zero change if anything, do you ignore it or do you have to synthesis it , but that makes no-sense when considering minUTxOValue ?

I’ve tried several approaches writing a wrapper to test things nothing works to date, if I understand minUTxOValue and if there was change the account receiving the change also has to have 1 ADA ? But In the Scenarios I’m trying to construct there is no change there is only one receiving account getting everything minus the fee.

This is the construct for the transaction

TX_FEE=$(cardano-cli transaction calculate-min-fee
–tx-body-file matx.raw
–tx-in-count 2
–tx-out-count 1
–witness-count 1
–testnet-magic 1097911063
–protocol-params-file protocol.json | awk ‘{print $1}’)

cardano-cli transaction build-raw
–fee $TX_FEE
–invalid-hereafter $INVALIDAFTERSLOT
–out-file matx.raw

After signing and running the script I get the following output

TX_FEE : 173201
Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraMary (ApplyTxError [LedgerFailure (UtxowFailure (UtxoFailure (ValueNotConservedUTxO (Value 2814812 (fromList [(PolicyID {policyID = ScriptHash “6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7”},fromList [("",4)])])) (Value 2814812 (fromList )))))])

My thinking is if I can get this working then map it back to the initial minting problem

Anyway many thanks in advance for reading this.

Regards Richard

1 Like

What you’re trying is possible and your strategy and script are fine. The problem with the transaction you tried is that one of the inputs has 4 of a token 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7, but the output doesn’t. Both the lovelace and the token counts must balance in a non-minting transaction. The error message cryptically reports that. You’ll need either to add the 4 token to the output or to use a token less input.

1 Like

Many thanks for your quick replay , very much appreciated.

As a follow-up is this the lovelace + 2 as below summed to 4 the token count ?

lCaradanoT1:~/cardanoTestNetKeys$ cardano-cli query utxo --address $(cat payment.addr) --testnet-magic 1097911063
TxHash TxIx Amount

63f176c3fe800d8ba75737329e4b6d939c6b44331de46255366d7775b9f2c2fe 0 1407406 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7
adf234827b070dd7d15302b0f1d8c09eb62bc2e21136b51695c4160c7c9505a6 0 1407406 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7

Could you point me at any documentation that explains the token count and the breakdown from the above output, so I know how you incorporate it ?

I did wonder about the Amount file past plus sign but could not find anything to explain it

Again many thanks your a star

The “Send the new native asset to another address” section of the token documentation shows the format for build-raw and how the output query utxo looks. Basically, the number of tokens are followed by a space, then the policy ID, and finally a period (".") followed by the asset name if the asset is named.

In your example, the asset name was blank: that’s why the error message had [("",4)] in it, which meant that there were 4 tokens with an empty name. Your transaction output should probably read --tx-out $PAYADDR2+$SENDAMOUNT+"4 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7", though there is a chance it might need to have a period at then end like –tx-out $PAYADDR2+$SENDAMOUNT+"4 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7.". (I haven’t used assets with blank names, so I’m not sure of the syntax.)

P.S. If you use the --out-file option on query utxo, the results will be stored in a JSON file that might be easier to parse and extract information from (with a tool like jq).


Just to close out my lack of understanding may help others as my original misunderstanding was I’d downloaded from the faucet the NFT option for test ADA which came with this NFT with a blank token name.

This threw me as almost all examples and tutorials begin with the notion of normal ada not test ada which has a blank NFT associated with it. I subsequently went back to faucet and download some normal test ada.

So lessons learned

  1. I was able to consolidate multiples inputs into a single output on a second address with a blank token name with the following, so no period required

cardano-cli transaction build-raw
–fee $TX_FEE
–invalid-hereafter $INVALIDAFTERSLOT
–out-file matx.raw

NB Its important to NOTE that the token quantity here is the sum of the number of NFT tokens of the two input transactions in my case this was 4 (2+2) token see below

1407406 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7
1407406 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7

  1. Having minted my first NFT , I was then able to then mint a Second NFT with a different name using remaining Lovelace (change) from the first NFT mint and send the resulting second NFT to a second address like thus

cardano-cli transaction build-raw
–fee $TX_FEE
–invalid-hereafter $INVALIDAFTERSLOT
–out-file matx.raw

The result is I’m beginning to understand that balancing the inputs and out puts means all the tokens and NFT’s in the seeding transaction. Seems all NFTs need to be assocaited with at least the minimum ada - which makes sense.

Next test is creating multiple NFTS on a single transaction to see the resulting structure.

Again my thanks to bwbush and all above.

Regards Damfoolcat


Great testing and result there, hope it will helps community by reaching this thread.
I changed the thread name to make others more easy to find solution with the same topic.

1 Like

FYI: Version 1.27.0 of cardano-cli has a command for computing the minimum value:

Usage: cardano-cli transaction calculate-min-value (--genesis FILE | 
                                                    --protocol-params-file FILE)
                                                    --multi-asset VALUE
  Calculate the minimum value for a transaction