2

I am trying to create a token and I've been following the instructions for here: https://developers.cardano.org/docs/native-tokens/minting/#minting-native-assets

This is on testnet.

Here is some info:

tokenamount="10000000"

tokenname1="Theo2"

My test account has: 10000000 (10 Ada)

So I am trying to send two tokens.

This is the transaction:

fee=$(cardano-cli transaction calculate-min-fee --tx-body-file matx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 1 --testnet-magic 1097911063 --protocol-params-file protocol.json | cut -d " " -f1)
 
output=$(expr $funds - $fee) 


receiver="addr_test1qry8yex9gs43tvkzgsvwzg5z7zaak4p2rc8j3qd08vfjtry5vsaj3psfewzrn8nyajhn8qcqdyvkt7uvy6hvaqmguzysaq09fn"
receiver_output="10000000"
txhash="34e30197ad4c5228603256a870ede98720c14b6b6d67fda4e2bc075cc0d35414"
txix="0"
funds="10000000"

cardano-cli transaction build-raw  \
--fee $fee  \
--tx-in $txhash#$txix  \
--tx-out $receiver+$((receiver_output-$fee))+"2 $policyid.$tokenname1"  \
--tx-out $address+$output+"9999998 $policyid.$tokenname1"  \
--out-file rec_matx.raw

fee=$(cardano-cli transaction calculate-min-fee --tx-body-file rec_matx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 1 --testnet-magic 1097911063 --protocol-params-file protocol.json | cut -d " " -f1)

output=$(expr $funds - $fee - 1000000)

cardano-cli transaction build-raw  \
--fee $fee  \
--tx-in $txhash#$txix  \
--tx-out $receiver+$((receiver_output-$fee))+"2 $policyid.$tokenname1"  \
--tx-out $address+$output+"9999998 $policyid.$tokenname1"  \
--out-file rec_matx.raw


cardano-cli transaction sign  \
--signing-key-file payment.skey  \
--signing-key-file policy/policy.skey  \
--testnet-magic 1097911063 --tx-body-file rec_matx.raw  \
--out-file rec_matx.signed

cardano-cli transaction submit --tx-file rec_matx.signed --testnet-magic 1097911063

When I submit the transaction I get the following error:

$ cardano-cli transaction submit --tx-file matx.signed --testnet-magic 1097911063
Command failed: transaction submit  Error: Error while submitting tx: 
ShelleyTxValidationError ShelleyBasedEraAlonzo 
(ApplyTxError [UtxowFailure (WrappedShelleyEraFailure
 (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [(PolicyID 
{policyID = ScriptHash "09d4abb4a6a768e678332433c789d82c4e3e45a9d98b1722f597fa5c"},fromList [("Theo2",10000000)])])) (Value 10000000 (fromList [(PolicyID {policyID = ScriptHash 
"09d4abb4a6a768e678332433c789d82c4e3e45a9d98b1722f597fa5c"},fromList 
[("Theo2",10000000)])]))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure 
(BadInputsUTxO (fromList [TxInCompact (TxId {_unTxId = SafeHash 
"05117382cb40f2fa194c9a113159372228e54055a07d48c8c0e0e7ac2070b20d"}) 0]))))])

I think the error is related to the amount not matching, but I can't quite figure it out.

Any help would be much appreciated.

P.S: I'm doing this via Daedalus on Windows

Thanks, Chris

2 Answers 2

5

Where you submit transactions to the blockchain, you typically go through the following steps.

  1. build the transaction without any fees
  2. calculate the transaction fees
  3. rebuild the transaction with the correct fees
  4. sign the transactions with the appropriate witness
  5. submit the transaction to the blockchain

Each of these five operations has a specific call on the cardano cli:

  1. cardano-cli transaction build-raw
  2. cardano-cli transaction calculate-min-fee
  3. same as step 1
  4. cardano-cli transaction sign
  5. cardano-cli transaction submit

You'll need to perform each of these operations to successfully submit to the blockchain. Some tips on creating the transactions:

  • depending on what shell you're using, you may be need to wrap the arguments in a quote or double-quote so --tx-in "$txhash#$txix" instead of --tx-in $txhash#$txix. This is because many shells interpret anything to the right of # as a comment
  • after you calculate the fees, make sure to adjust the sum of the tx-outs by the fee e.g. subtract the fee. If you fail to do so do, you'll get a ValueNotConservedUTxO message indicating the inputs do not balance the outputs
1
  • Thanks Matt, I have followed all the instructions as listed in the Cardano doc before I got to submit part. I'll try your suggestion and see if that works for me. Nov 1, 2021 at 23:04
1

Regarding to the docs:

Problem: ValueNotConservedUTxO

Diagnosis: Value not Conserved: (Input UTXO ≠ Fee + Amount sent + Change)

Solution: Check that output amount is equal to input amount

You can find another problems here: Diagnosing transactions problems and troubleshooting

In other words, it's because your transaction is not balanced.

[EDIT] In your case:

  • Your receiver_output is wrong because is 10000000 (10 ADA), equal to your funds. In the tutorial, they have 1,000 ADA.
  • You're sending to the receiver: receiver_output-fee and you already deducted fees from output. So you should send to receiver only receiver_output. Try using receiver_output=2000000 (2 ADA)

In general, always follow process from Matt Ho.

2
  • Thanks @georgeos, I've updated the commands that I used, can you please let me know if you can see anything missing. Thanks in advance. Nov 11, 2021 at 23:33
  • @hatsrumandcode Check my updated answer.
    – georgeos
    Nov 19, 2021 at 23:26

Your Answer

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

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