<p>Looks like you don't account for change return value (your <code>$output</code> variable which is zero).</p>
<p>Your transaction spends some UTxO to pay the fee but the rest of this UTxOs ADA has to go somewhere (hence the <code>value not conserved</code> error).</p>
<p>I think you need to look up the ADA value of the <code>--tx-in &quot;$txhash#$txix&quot;</code> (your <code>$funds</code> variable?) and subtract fee from it, which is the unspent ADA you get back.</p>

CC BY-SA 4.0
2021-12-03T15:50:43.077Z
Thanks I was missing the output=$(expr $funds - $fee)
user2859698
CC BY-SA 4.0
2021-12-06T13:20:33.290Z
Nice! Please mark the question as answered :-)
sorki
CC BY-SA 4.0
2021-12-03T13:09:33.810Z
2021-12-03T13:09:33.810Z
sorki
<p>I'm following these <a href="https://developers.cardano.org/docs/native-tokens/minting/#fund-the-address" rel="nofollow noreferrer">steps</a> and I get the OutputTooSmallUTxO error.
Not sure what I missed from the steps but here's my parameters and the error as a whole.</p>
<p>tokenname1=&quot;Testtoken&quot;
tokenname2=&quot;SecondTesttoken&quot;
tokenamount=&quot;100000000&quot;
output=&quot;0&quot;</p>
<p>fee=&quot;300000&quot;
txhash=&quot;8a7e45c02cf25cb1b9870fbcc87b61d61cefb514ccfb960bcc7651023ea7ffb2&quot;
txix=&quot;0&quot;
funds=&quot;1000000000&quot;
policyid=$(cat policy/policyID)</p>
<p>cardano-cli transaction build-raw <br />
--fee $fee <br />
--tx-in &quot;$txhash#$txix&quot; <br />
--tx-out $address+$output+&quot;$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2&quot; <br />
--mint=&quot;$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2&quot; <br />
--minting-script-file policy/policy.script <br />
--out-file matx.raw</p>
<p>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 &quot; &quot; -f1) (This was not incluted in the tutorial and i added it from a block post i found here in reference to a similar issue)</p>
<p>cardano-cli transaction build-raw <br />
--fee $fee <br />
--tx-in &quot;$txhash#$txix&quot; <br />
--tx-out $address+$output+&quot;$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2&quot; <br />
--mint=&quot;$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2&quot; <br />
--minting-script-file policy/policy.script <br />
--out-file matx.raw</p>
<p>cardano-cli transaction sign  <br />
--signing-key-file payment.skey  <br />
--signing-key-file policy/policy.skey  <br />
--testnet-magic 1097911063 --tx-body-file matx.raw  <br />
--out-file matx.signed</p>
<p>cardano-cli transaction submit --tx-file matx.signed --testnet-magic 1097911063</p>
<p>Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (OutputTooSmallUTxO [(Addr Testnet (KeyHashObj (KeyHash &quot;63c7e6f65c0185e0afa19657977c86e663873143569b665d23f532ea&quot;)) StakeRefNull,Value 0 (fromList [(PolicyID {policyID = ScriptHash &quot;68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136&quot;},fromList [(&quot;SecondTesttoken&quot;,100000000),(&quot;Testtoken&quot;,100000000)])]),SNothing)]))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 1000000000 (fromList [(PolicyID {policyID = ScriptHash &quot;68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136&quot;},fromList [(&quot;SecondTesttoken&quot;,100000000),(&quot;Testtoken&quot;,100000000)])])) (Value 177601 (fromList [(PolicyID {policyID = ScriptHash &quot;68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136&quot;},fromList [(&quot;SecondTesttoken&quot;,100000000),(&quot;Testtoken&quot;,100000000)])])))))])
antonis@adastp:~/tokens$ echo $cardano-cli transaction submit --tx-file matx.signed --testnet-magic 1097911063^C</p>
<p>--tx-in
addr_test1vp3u0ehktsqctc905xt909musmnx8pe3gdtfkejay06n96shpzd3t+0+100000000 68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136.Testtoken + 100000000 68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136.SecondTesttoken</p>
<p>--tx-out
8a7e45c02cf25cb1b9870fbcc87b61d61cefb514ccfb960bcc7651023ea7ffb2#0</p>

<native-assets>
OutputTooSmallUTxO error
# OutputTooSmallUTxO error

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

I'm following these [steps](https://developers.cardano.org/docs/native-tokens/minting/#fund-the-address) and I get the OutputTooSmallUTxO error.
Not sure what I missed from the steps but here's my parameters and the error as a whole.

tokenname1="Testtoken"
tokenname2="SecondTesttoken"
tokenamount="100000000"
output="0"

fee="300000"
txhash="8a7e45c02cf25cb1b9870fbcc87b61d61cefb514ccfb960bcc7651023ea7ffb2"
txix="0"
funds="1000000000"
policyid=$(cat policy/policyID)

cardano-cli transaction build-raw   
--fee $fee   
--tx-in "$txhash#$txix"   
--tx-out $address+$output+"$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2"   
--mint="$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2"   
--minting-script-file policy/policy.script   
--out-file matx.raw

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) (This was not incluted in the tutorial and i added it from a block post i found here in reference to a similar issue)

cardano-cli transaction build-raw   
--fee $fee   
--tx-in "$txhash#$txix"   
--tx-out $address+$output+"$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2"   
--mint="$tokenamount $policyid.$tokenname1 + $tokenamount $policyid.$tokenname2"   
--minting-script-file policy/policy.script   
--out-file matx.raw

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

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 (OutputTooSmallUTxO [(Addr Testnet (KeyHashObj (KeyHash "63c7e6f65c0185e0afa19657977c86e663873143569b665d23f532ea")) StakeRefNull,Value 0 (fromList [(PolicyID {policyID = ScriptHash "68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136"},fromList [("SecondTesttoken",100000000),("Testtoken",100000000)])]),SNothing)]))),UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 1000000000 (fromList [(PolicyID {policyID = ScriptHash "68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136"},fromList [("SecondTesttoken",100000000),("Testtoken",100000000)])])) (Value 177601 (fromList [(PolicyID {policyID = ScriptHash "68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136"},fromList [("SecondTesttoken",100000000),("Testtoken",100000000)])])))))])
antonis@adastp:~/tokens$ echo $cardano-cli transaction submit --tx-file matx.signed --testnet-magic 1097911063^C

--tx-in
addr\_test1vp3u0ehktsqctc905xt909musmnx8pe3gdtfkejay06n96shpzd3t+0+100000000 68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136.Testtoken + 100000000 68d7df6ec365f5d9885c451e58e8994741c1970211c01843703f6136.SecondTesttoken

--tx-out
8a7e45c02cf25cb1b9870fbcc87b61d61cefb514ccfb960bcc7651023ea7ffb2#0

**Tags:** native-assets

---

## 1 answers

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

Looks like you don't account for change return value (your `$output` variable which is zero).

Your transaction spends some UTxO to pay the fee but the rest of this UTxOs ADA has to go somewhere (hence the `value not conserved` error).

I think you need to look up the ADA value of the `--tx-in "$txhash#$txix"` (your `$funds` variable?) and subtract fee from it, which is the unspent ADA you get back.

> **Comments:**
> **username_0**: Thanks I was missing the output=$(expr $funds - $fee)  
> **username_1**: Nice! Please mark the question as answered :-)  

---

