ValueNotConservedUTxO with 1input 1 output

Am trying to send the remaining 1310316 tAda Lovelace from payment.addr to my paymentwithstake.addr

cardano-cli query utxo payment.addr

 cardano-cli query utxo \
  --address $(cat payment.addr) \
  --testnet-magic 1097911063
                       TxHash                                 TxIx        Amount

33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e 0 1310316 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7 + TxOutDatumHashNone

Build raw transaction

cardano-cli transaction build-raw \
--tx-in 33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e#0 \
--tx-out $(cat paymentwithstake.addr)+0 \
--invalid-hereafter 0 \
--fee 0 \
--out-file tx.raw

Calculate fee

cardano-cli transaction calculate-min-fee \
--tx-body-file tx.raw \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 1 \
--byron-witness-count 0 \
--testnet-magic 1097911063 \
--protocol-params-file protocol.json

171177

Find paymentwithstake.addr receiving amount
expr 1310316 - 171177

1139139

cardano-cli query tip
cardano-cli query tip --testnet-magic 1097911063

{
“epoch”: 157,
“hash”: “656344881d5742e442d2e23b091bbaad7b493086264b1640b4ce0b06c9cd38c8”,
“slot”: 37706305,
“block”: 2925642,
“era”: “Alonzo”,
“syncProgress”: “100.00”
}

cardano-cli transaction build-raw

cardano-cli transaction build-raw \
--tx-in 33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e#0 \
--tx-out $(cat paymentwithstake.addr)+1139139 \
--invalid-hereafter 37706505 \
--fee 171177 \
--out-file tx.raw

Sign the transaction

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

Submit transaction

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

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 1310316 (fromList [(PolicyID {policyID = ScriptHash “6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7”},fromList [(“”,2)])])) (Value 1310316 (fromList )))))])

I was told that ValueNotConservedUTxO is the result of
Value not Conserved: (Input UTXO ≠ Fee + Amount sent + Change)

But the value I calculated adds up to 0 as I am trying to send out all my tAda. What am I doing wrong?

Please help, thanks in advance!

Do u have the latest files for alonzo?

This is not the stake address?

cardano-node --version

cardano-node 1.29.0 - linux-x86_64 - ghc-8.10
git rev 4c59442958072657812c6c0bb8e0b4ab85ce1ba2

cardano-cli query utxo
–address $(cat paymentwithstake.addr)
–testnet-magic 1097911063

                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------
3ec3cf246433b82a7b5db849167d0b89a2cc4e26d71b4b1fd9763ff9a339f7b8     0        699304820 lovelace + TxOutDatumHashNone
ffe056252d1d2f880fecfcb44d731ab6a523fa6129979b7276a07d1dc30ddfaf     0        100000000 lovelace + TxOutDatumHashNone

It has something to do with that 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7 that are in the UTXO is that some custom token or ??

…try including that in the tx-out as well…

You meant TxIn. Yeah, tried that too. TxIn with both #0 and # and returns invalid. I drew that token from the faucet as test token instead of tAda. Maybe they are unspendable.

cardano-cli transaction build-raw \
> --tx-in 33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e#0 \
> --tx-in 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7#0 \
> --tx-out $(cat paymentwithstake.addr)+0 \
> --invalid-hereafter 0 \
> --fee 0 \
> --out-file tx.raw

option --tx-in:
unexpected “#”
expecting hexadecimal digit
Incorrect transaction id format:: “6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7”

No need for additional tx-in as it is a part of the same utxo.

But you need to include it in tx-out.

Try:

--tx-out $(cat paymentwithstake.addr)+0+"2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7"

Included Tx-out with + “2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7” and returns error: Output too small. But I am spending more than 1 ada. This isn’t a big problem as I am only doing this on testnet and the amount is small. Just don’t know why this is happening.

cardano-cli query utxo \
  --address $(cat payment.addr) \
  --testnet-magic 1097911063
                       TxHash                                 TxIx        Amount

33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e 0 1310316 lovelace + 2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7 + TxOutDatumHashNone

Build raw:

cardano-cli transaction build-raw \
--tx-in 33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e#0 \
--tx-out $(cat paymentwithstake.addr)+0+"2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7" \
--invalid-hereafter 0 \
--fee 0 \
--out-file tx.raw

Calculate min fee:

cardano-cli transaction calculate-min-fee \
--tx-body-file tx.raw \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 1 \
--byron-witness-count 0 \
--testnet-magic 1097911063 \
--protocol-params-file protocol.json

172717

expr 1310316 - 172717
1137599

cardano-cli query tip --testnet-magic 1097911063
{
“epoch”: 158,
“hash”: “21783ceb1c57cb73307095a31be042d6525e31f54361f5fce7829e958294e66d”,
“slot”: 37927435,
“block”: 2932687,
“era”: “Alonzo”,
“syncProgress”: “100.00”
}
Build raw:

cardano-cli transaction build-raw \
--tx-in 33933aa41be6fb2cbb6c651bb63fdd0f2afeba5567b5c3cd0bf592327c3a408e#0 \
--tx-out $(cat paymentwithstake.addr)+1137599+"2 6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7" \
--invalid-hereafter 37927635 \
--fee 172717 \
--out-file tx.raw

Sign transaction:

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

Submit signed:

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

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (OutputTooSmallUTxO [(Addr Testnet (KeyHashObj (KeyHash “a1fcaf2e76e666fb34b32fdd96178f22afe153bccfb4c25149db874e”)) (StakeRefBase (KeyHashObj (KeyHash “09b3f208ac212b053156988366f49726b63e19155a7939651d467476”))),Value 1137599 (fromList [(PolicyID {policyID = ScriptHash “6b8d07d69639e9413dd637a1a815a7323c69c86abbafb66dbfdb1aa7”},fromList [("",2)])]),SNothing)])))])

When having ADA only in the transaction the minimum as per protocol parameters is 1ADA.
If having other tokens in the transaction that minimum gets higher and depends on the number of tokens and their size.

The 1.13ADA you are sending is probably not enough.

See here for explanation about min value:
https://github.com/input-output-hk/cardano-ledger-specs/blob/master/doc/explanations/min-utxo.rst

And here for a calculator:
https://mantis.functionally.io/how-to/min-ada-value/

Try sending 1.5ADA and see if it works or calculate the exact amount.