ValueNotConservedUTxO error when re-submitting pool registration

Hi All,
Im getting the error “ValueNotConservedUTxO” when re-submitting a pool registration. The pool is already registered and im adding a second owner. Ive calculated minimum fee, built and signed the transaction, when i submit the transaction to the network i get the following error:

`transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 2752416 (fromList [])) (Value 2852440 (fromList [])))))])`

After signing with:

cardano-cli transaction sign \
    --tx-body-file poolreregtx.raw \
    --signing-key-file $HOME/cold-keys/operator_payment.skey \
    --signing-key-file $HOME/cold-keys/node.skey \
    --signing-key-file $HOME/cold-keys/operator_stake.skey \
    --signing-key-file $HOME/cold-keys/owner_1_stake.skey \
    --signing-key-file $HOME/cold-keys/owner_2_stake.skey \
    --mainnet \
    --out-file poolreregtx.signed

Value not conserved is most often … value not conserved.

Have you recalculated the output after calculating the fee?

Have you incremented the --witness-count (since you have an additional owner, now) when calculating the fee?

Hi, i had recalculated the fee, and had bumped the witness count to 3 from 2, im wondering if my balance is not enough and that is what is giving the error (2.752 ADA in the operators balance)

fee=$(cardano-cli transaction calculate-min-fee \
    --tx-body-file poolreregtx.tmp \
    --tx-in-count ${txcnt} \
    --tx-out-count 1 \
    --mainnet \
    --witness-count 3 \
    --byron-witness-count 0 \
    --protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee

I’m counting five witnesses (the signing keys in the sign step), but I may have understood something wrong, there.

The 2.7 ADA should be enough. The transaction should not cost more than .2 ADA and 1 ADA in the outgoing UTxO is enough.

Yeah i think you are right, I’m probably not getting the witnesses number right. The balance is not the issue (i just added from funds and it didn’t change the outcome).

still getting the same error with 5 witnesses

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (ValueNotConservedUTxO (Value 11752416 (fromList [])) (Value 2867928 (fromList [])))))])

calculated fee was:

echo fee: $fee
fee: 216805

using:

fee=$(cardano-cli transaction calculate-min-fee \
    --tx-body-file poolreregtx.tmp \
    --tx-in-count ${txcnt} \
    --tx-out-count 1 \
    --mainnet \
    --witness-count 5 \
    --byron-witness-count 0 \
    --protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee

Hmm, that discrepancy is getting higher. Did you add your newly put in funds to the tx-in, but did not adapt the output?

using this:

cardano-cli query utxo \
    --address $(cat operator_payment.addr) \
    --mainnet > fullUtxo.out

tail -n +3 fullUtxo.out | sort -k3 -nr > balance.out

cat balance.out

tx_in=""
total_balance=0
while read -r utxo; do
    in_addr=$(awk '{ print $1 }' <<< "${utxo}")
    idx=$(awk '{ print $2 }' <<< "${utxo}")
    utxo_balance=$(awk '{ print $3 }' <<< "${utxo}")
    total_balance=$((${total_balance}+${utxo_balance}))
    echo TxHash: ${in_addr}#${idx}
    echo ADA: ${utxo_balance}
    tx_in="${tx_in} --tx-in ${in_addr}#${idx}"
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}

and then building the raw tx with this and calculating the minimum fee afterwards:

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat operator_payment.addr)+${total_balance} \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee 0 \
    --certificate-file pool_reregistration.cert \
    --certificate-file delegation_owner_1.cert \
    --certificate-file delegation_owner_2.cert \
    --out-file poolreregtx.tmp

ahhhh… i wasn’t calculating the change output (facepalm)

txOut=$((${total_balance}-${fee}))
echo txOut: ${txOut}

1 Like

Looks good.

After calculating the minimum fees, when building the raw transaction again with the correct fee, there should be $total_balance-$fee in --tx-out. Or is it stored in a variable?

The error message clearly says that there are only 2.8 ADA in there, where there should be around 11 ADA.

(Also: Try 4 witnesses, in case we are both wrong and it’s in the middle.)

Yes you are correct, I wasn’t calculating the change output before building the raw transaction. Also, witnesses should have been 4 like you suggest :slight_smile:

thanks for the help!

1 Like

Anyway, you can use “cardano-cli transaction build” instead of “build-raw” and it will automatically calculate the minimum fee required for the transaction while creating the transaction file. I don’t know why the guides available don’t update the transactions. You cannot use “transaction build” yet with hardware wallets (because the firmware does not allow yet Alonzo era transactions), but this will be also available sometime in the near future.

1 Like

Aargh, I even recommended that in another thread. But you still need to get the --witness-override correct, there, too.