<p>Basically, the error <code>ValueNotConservedUTxO</code> means that your transaction is not balanced. Take a look on this <a href="https://cardano.stackexchange.com/a/4371/1231">answer</a> to follow the appropiate process to submit transactions.</p>
<p>Other points to consider:</p>
<ol>
<li><p>Depending how you're building and submitting your transactions, but consider that your transactions need to be confirmed in order to get your UTxOs updated.</p>
</li>
<li>
<blockquote>
<p>When I run the script to mint a token and then immediately run the script to send that token to a wallet, I get this error</p>
</blockquote>
</li>
</ol>
<ul>
<li>You can't mint a NFT and send it immediately in another transaction because you need to wait until the first transaction (your NFT) get reflected on your UTxOs</li>
<li>But you can mint and send the NFT in the same transaction. I think this is the best approach.</li>
</ul>
<pre><code>    cardano-cli transaction build-raw \
    --fee &lt;fee&gt; \
    --tx-in &lt;tx_in&gt; \
    --tx-out &lt;your_address&gt;+&lt;change&gt; \
    --tx-out &lt;destination_address&gt;+&lt;minUtxO&gt;+1 &lt;nft&gt; \
    --mint=1 &lt;nft&gt; \
    --minting-script-file &lt;policy-file&gt; \
    --metadata-json-file &lt;metadata-file&gt; \
    --invalid-hereafter=&lt;slot&gt; \
    --out-file &lt;outputfile.raw&gt;
</code></pre>
<ol start="3">
<li>
<blockquote>
<p>A similar error happens if I run the script to mint a token and then immediately re-run it.</p>
</blockquote>
</li>
</ol>
<ul>
<li>Consider that your UTxOs  get re ordered every time you submit a transaction.</li>
</ul>

CC BY-SA 4.0
2021-12-03T01:35:26.317Z
This was very helpful; thank you. The problem was related to UTxOs not being updated, as you said. I'll attempt to mint and send in the same transaction and see how it goes.
sdub
CC BY-SA 4.0
2021-12-02T21:30:41.410Z
2021-12-02T21:36:19.133Z
2021-12-02T21:36:19.133Z
georgeos
<p>I recently wrote some scripts that mint and send tokens. When I run the script to mint a token and then immediately run the script to send that token to a wallet, I get this error:</p>
<pre><code>Error: Command failed: cardano-cli transaction submit --testnet-magic 1097911063 --tx-file ./tmp/tx_n5sm4btig.signed
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationErrorShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [(PolicyID {policyID = ScriptHash &quot;1a1b09e939ec7fd1b60c1e4d71808926421079f679e79d1e9f36561a&quot;},fromList [(&quot;TestNFT&quot;,1)])])) (Value 992262587 (fromList [(PolicyID {policyID = ScriptHash &quot;1a1b09e939ec7fd1b60c1e4d71808926421079f679e79d1e9f36561a&quot;},fromList [(&quot;TestNFT&quot;,1)]),(PolicyID {policyID = ScriptHash &quot;584af528f36789c8d5cc9336ec258326cbea8b3983d9d6d40cdc5bce&quot;},fromList [(&quot;TestNFT&quot;,1)]),(PolicyID {policyID = ScriptHash &quot;6eee44f15e11b84d33bcaaff8096d36fa400f6cb8eaa14007d6fac1b&quot;},fromList [(&quot;TestNFT&quot;,1)]),(PolicyID {policyID = ScriptHash &quot;b294451d861bc02b49591d9413a12f8b24a0f17c57940c9d78d1074c&quot;},fromList [(&quot;TestNFT&quot;,1)]),(PolicyID {policyID = ScriptHash &quot;e7ba14bfcb30f171b106ea15984cd25101d73f72fc89f2bb864ff600&quot;},fromList [(&quot;TestNFT&quot;,1)])]))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {_unTxId = SafeHash &quot;7d667aef6319a22a71903fca4d88b69cea24e23c36120e11f34738aa8d90da07&quot;}) 0]))))])
</code></pre>
<p>A similar error happens if I run the script to mint a token and then immediately re-run it. It seems like rapid back-to-back transactions cause this. Am I doing something incorrectly?</p>
<p>Edit: I wanted to add that the scripts work as expected if there is a pause (&gt;~1 minute) between each execution.</p>
<p>Any help is appreciated, and I apologize if this is a basic question!</p>

<cardano-cli><transaction>
Back-to-back transactions produce ValueNotConservedUTxO error
# Back-to-back transactions produce ValueNotConservedUTxO error

(Asked by: username_0 on 2021-12-02)

I recently wrote some scripts that mint and send tokens. When I run the script to mint a token and then immediately run the script to send that token to a wallet, I get this error:
Error: Command failed: cardano-cli transaction submit --testnet-magic 1097911063 --tx-file ./tmp/tx_n5sm4btig.signed
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationErrorShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList [(PolicyID {policyID = ScriptHash "1a1b09e939ec7fd1b60c1e4d71808926421079f679e79d1e9f36561a"},fromList [("TestNFT",1)])])) (Value 992262587 (fromList [(PolicyID {policyID = ScriptHash "1a1b09e939ec7fd1b60c1e4d71808926421079f679e79d1e9f36561a"},fromList [("TestNFT",1)]),(PolicyID {policyID = ScriptHash "584af528f36789c8d5cc9336ec258326cbea8b3983d9d6d40cdc5bce"},fromList [("TestNFT",1)]),(PolicyID {policyID = ScriptHash "6eee44f15e11b84d33bcaaff8096d36fa400f6cb8eaa14007d6fac1b"},fromList [("TestNFT",1)]),(PolicyID {policyID = ScriptHash "b294451d861bc02b49591d9413a12f8b24a0f17c57940c9d78d1074c"},fromList [("TestNFT",1)]),(PolicyID {policyID = ScriptHash "e7ba14bfcb30f171b106ea15984cd25101d73f72fc89f2bb864ff600"},fromList [("TestNFT",1)])]))))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {_unTxId = SafeHash "7d667aef6319a22a71903fca4d88b69cea24e23c36120e11f34738aa8d90da07"}) 0]))))])

A similar error happens if I run the script to mint a token and then immediately re-run it. It seems like rapid back-to-back transactions cause this. Am I doing something incorrectly?
Edit: I wanted to add that the scripts work as expected if there is a pause (>~1 minute) between each execution.
Any help is appreciated, and I apologize if this is a basic question!

**Tags:** cardano-cli, transaction

---

## 1 answers

### Answer by username_1 on 2021-12-02. Score: 0 | Accepted answer

Basically, the error ValueNotConservedUTxO means that your transaction is not balanced. Take a look on this answer to follow the appropiate process to submit transactions.
Other points to consider:

Depending how you're building and submitting your transactions, but consider that your transactions need to be confirmed in order to get your UTxOs updated.



When I run the script to mint a token and then immediately run the script to send that token to a wallet, I get this error




You can't mint a NFT and send it immediately in another transaction because you need to wait until the first transaction (your NFT) get reflected on your UTxOs
But you can mint and send the NFT in the same transaction. I think this is the best approach.

    cardano-cli transaction build-raw \
    --fee  \
    --tx-in  \
    --tx-out + \
    --tx-out ++1  \
    --mint=1  \
    --minting-script-file  \
    --metadata-json-file  \
    --invalid-hereafter= \
    --out-file 




A similar error happens if I run the script to mint a token and then immediately re-run it.




Consider that your UTxOs  get re ordered every time you submit a transaction.

> **Comments:**
> **username_0**: This was very helpful; thank you. The problem was related to UTxOs not being updated, as you said. I'll attempt to mint and send in the same transaction and see how it goes.  

---

