ValueNotConservedUTxO with 17 tx-out

Hi,

I’m trying to submit one transaction with 17 tx-out in total but I always end with a ValueNotConservedUTxO error. I understand the error, a fee calculation problem but I’m unable to calculate the correct fee.

Those are the steps:

cardano-cli query protocol-parameters --mainnet --out-file protocol.json
cardano-cli query utxo --mainnet --address $(cat base.addr)
cardano-cli transaction build-raw \
--tx-in d47e2b50887793d9f26f1958e4bb436f2dfb1f0f8a09ac57266ec67dcdeba1e7#0 \
--tx-out addr1qx63xnx5ru83ad5crw4kj2gns9ewrcfxexq6xffxfe9ggmlx54dl70jzu0kk7pvcj4tlssqdxwuj3zjcprxms58yyhes3rqw9f+1000000 \
--tx-out addr1qxcm8ggurwrptg3pdsx8t7hvfw6uc3unymck3g2qvwjssffns3mrsuyr8jz4tlcsj36l2sar09erlg4ysl8ktyaydjaqdy5g6m+1000000 \
--tx-out addr1q8uh305uef45242se2w504jfzr6a862kq70sdrn2pkmyhn86akft3x4m6qey5rh47huknz70kkqg3jnuumetj2k35ekqskwu8x+1000000 \
--tx-out addr1q8ccpn5s7zujqwvxcn9pywwfhjrplq8rd5mlcdfxr2rhfh05mqkylxrtlpvv3j6dupg86usn7me467qhtlfy2qwdhkfqey834t+1000000 \
--tx-out addr1q8442qa8enf2arc0xxtj3nzac6r7wxuhe3swexl50lsjzyr5e7sdangw8c2p73dg7h0yrem4nghx32rf0qupnacx3gnq67fr0k+1000000 \
--tx-out addr1qxedk5vvzqxphz343930e8apd6qcpcdu6y9y6tpr4w6a048skegda6t5k7kcy6869ygtwy9ugwemkjlkyemqxmrg8y0qgf56jf+1000000 \
--tx-out addr1qxr9lr7ktw4gdwvlf5t96mmvh0mp8vk8d8n6lm6fkzh7hg6ymx29m3z9thg2ea5y5ta89x3jjw2awnywy0vhxmc9vcas7efrvm+3466044 \
--tx-out addr1q8l8qx2w34ynkr35rqduxem0v89ytps0cmw7lx0ygu76hfl2vrkkprjylf5lk2d3sleruy02hql0kmne2xwfwkmvdu8s66cxey+9229441 \
--tx-out addr1qymyygvxatmqny93tx8s0pgdzg8m5uspj42vag3ht4rkvxkgjpkrqx3x89gvct9dwn2n4j5uqeswsjmkv4u9eue9uznqap6xfr+11597895 \
--tx-out addr1qx545mnn9jj2kdjm4p20m6f3d7wsazssdrtv5z0924ggkcmfe79wn5llpn0qwa9caf2zzw3cf6xvt8svgd2d4623rmxs400ksp+13764726 \
--tx-out addr1qxwkzy0wmsj6sphgm6c3u67fprjkdk7uvylfy9848a5x5qt54wlk6qhgzeepyg8pctmc5xggwtdtmly5eag83c3888xq552gpa+21336612 \
--tx-out addr1qxvnqatm8pqnhsh2puta8qyn8swznkzr565plhw04pmr58vszufnxzamqtmtzrsflznn7460w9h6724ww05us3ecyynqfgmfzy+21915288 \
--tx-out addr1q97574g2h9d3rjyr73fz9mreh065crv6dyd6np4fagmrnvzfhm6yzmd2ujjpnyh88sltj8mkmugrfaqccftswsg56z3s5kwfyj+27695015 \
--tx-out addr1q9pu8fnsl8fyrcsd7pcsuseeaudastz8y0fvctlv52aq6m7v9mvxne5wau59k6hnjttr6zhdm6pcmgvl3sft0lgc2huqqrsym9+30909313 \
--tx-out addr1q9v4eg58kxaamgm3n8j6han7uy2rdlu07325pe0snjcvmh6v65kxlw8t47s75shpmnxyfffk9khyf3pmkkar3rrfvujsrj4mlr+110366945 \
--tx-out addr1q977jsj4qwuy8aq0e47akv09fk4snq4yzzml7pt6hlmhj0vc6pc2ul30zqa7fw5dggjkgthxq9d4jgjsmdj3fvypd7zsme2856+137919984 \
--tx-out addr1q8x23krcxh6pgxy5ju2frjgwlqs8x7urf84t2ekzwksws6qkwe279ckmnale4jrp2hejgaxnsd3u4lcdgec9um2xhx3q7449pf+219383008+"1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00026+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00569+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00579+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00585+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00593+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00615+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00783+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00785+ 1 37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46.SoccaDood00786+ 18 3a49d81a5dd6423eedce5481438f2bd7ea2ba38fcf502bd30b9c083b.BELGA1+ 1 9cf2d7934c499f7fe31069934c89e0013e9660f9fb2e98a6319d6574.ROGER8445" \
--invalid-hereafter 0 \
--fee 0 \
--out-file tx.draft
cardano-cli transaction calculate-min-fee \
--tx-body-file tx.draft \
--tx-in-count 1 \
--tx-out-count 17 \
--witness-count 1 \
--byron-witness-count 0 \
--mainnet \
--protocol-params-file protocol.json

With the calculated fee I make the necessary modification in previous command and 600 to the query tip for --invalid-hereafter and save as tx.raw

cardano-cli transaction sign \
--tx-body-file tx.raw \
--signing-key-file payment.skey \
--mainnet \
--out-file tx.signed
cardano-cli transaction submit \
--tx-file tx.signed \
--mainnet

And I get following error:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraMary (ApplyTxError [UtxowFailure (UtxoFailure (ValueNotConservedUTxO (Value 615858188 (fromList [(PolicyID {policyID = ScriptHash "37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46"},fromList [("SoccaDood00026",1),("SoccaDood00569",1),("SoccaDood00579",1),("SoccaDood00585",1),("SoccaDood00593",1),("SoccaDood00615",1),("SoccaDood00783",1),("SoccaDood00785",1),("SoccaDood00786",1)]),(PolicyID {policyID = ScriptHash "3a49d81a5dd6423eedce5481438f2bd7ea2ba38fcf502bd30b9c083b"},fromList [("BELGA1",18)]),(PolicyID {policyID = ScriptHash "9cf2d7934c499f7fe31069934c89e0013e9660f9fb2e98a6319d6574"},fromList [("ROGER8445",1)])])) (Value 613858188 (fromList [(PolicyID {policyID = ScriptHash "37d7547907da7bef6a73865721d19e06be903e57af8bc2f077b9ce46"},fromList [("SoccaDood00026",1),("SoccaDood00569",1),("SoccaDood00579",1),("SoccaDood00585",1),("SoccaDood00593",1),("SoccaDood00615",1),("SoccaDood00783",1),("SoccaDood00785",1),("SoccaDood00786",1)]),(PolicyID {policyID = ScriptHash "3a49d81a5dd6423eedce5481438f2bd7ea2ba38fcf502bd30b9c083b"},fromList [("BELGA1",18)]),(PolicyID {policyID = ScriptHash "9cf2d7934c499f7fe31069934c89e0013e9660f9fb2e98a6319d6574"},fromList [("ROGER8445",1)])]))))])

I tried calculating the fee by replacing the lovelace with 0 but I still get the same error.
Is there a limit in the number of tx-out?

Thank you.

According to the error message, your output is 613,858,188 lovelace, but the input is 615,858,188 lovelace: there is a 2,000,000 lovelace discrepancy. That 2,000,000 lovelace needs to be included in one of the outputs.

This isn’t a problem with the number of outputs: a transaction can have close to 500 outputs, actually.

Ooohhh nice catch, I indeed made a 2million lovelace error.

I ended up splitting in the transaction in two and thus recalculated everything and it went without a hitch.

Thanks for pointing out the obvious :smiley:

1 Like