SOLVED — Error: "ValueNotConservedUTXO" while changing pool cert — CoinCashew Step 18.4

SOLUTION: If native assets (tokens) are sent to your block producer’s payment.addr, CoinCashew step 18.4 will NOT function without altering the 2 commands as shown below:

tx.tmp command

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat payment.addr)+${total_balance}+"<AMOUNT OF TOKEN 1 RECIEVED> <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + <AMOUNT OF TOKEN 2 RECIEVED><TOKEN2POLICYID>.<TOKEN2ASSETNAME>" \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee 0 \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.tmp

tx.raw command

cardano-cli transaction build-raw \
    ${tx_in} \
   --tx-out $(cat payment.addr)+${txOut}+"<AMOUNT OF TOKEN 1 RECIEVED> <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + <AMOUNT OF TOKEN 2 RECIEVED><TOKEN2POLICYID>.<TOKEN2ASSETNAME>"  \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee ${fee} \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.raw

All other steps should remain the same, including calculating the fees.

You can find each token’s amount, policy ID, and asset name by searching your payment.addr in the Cardano Explorer.

I can create a transaction for you if you tell me exactly how much you want to transfer an what you want to do with the 2 tokens. I would send them to a different address, to be able to do “normal” transaction from the pledge address. The easiest would be if you also post the address, so that I can see the token names and the amounts, if not, then post the token names and amounts.

1 Like

The coincashew script by default uses all UTXOs as tx-in. What you could do is manually specifying the tx-in utxo by choosing the one that does not include the native tokens. In case you don’t want to do that but include all utxo’s, then you need to add the native tokens as part of tx-out.

Basically, the rule is that everything that is part of tx-in must equal the output which is tx-out + fees in your case.

1 Like

If you don’t want to keep that token in your payment address you can use tx-token.py from GitHub - Josef3110/stakepool_python_tools: some tools written in python to run cardano staking pools to send them to some other address.

It is not yet documented, but you can use the --help option to get an idea.

1 Like

Thank you for your responses everyone. Instead of sending the tokens out of my wallet, for now I just want to balance my Tx-Out to get the transaction to successfully submit.

Here are the commands I believe I need to alter:

tx.tmp command

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat payment.addr)+${total_balance} \
    --tx-out $(cat payment addr)+"1 <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + 1 <TOKEN2POLICYID>.<TOKEN2ASSETNAME>"  \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee 0 \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.tmp

calculating minimum fee

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

tx.raw command

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat payment.addr)+${txOut} \
    --tx-out $(cat payment addr)+"1 <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + 1 <TOKEN2POLICYID>.<TOKEN2ASSETNAME>"  \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee ${fee} \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.raw

Are there any other commands within CoinCashew step 18.4 that would need changed? Am I on the right track here? Or is there something I am missing?

This is not possible. A transaction output always has to contain ADA together with the token. Just put them both in the same --tx-out.

1 Like

Thank you Hepta, so like:

tx.tmp command

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat payment.addr)+${total_balance}+"1 <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + 1 <TOKEN2POLICYID>.<TOKEN2ASSETNAME>"  \ 
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee 0 \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.tmp

calculating minimum fee

fee=$(cardano-cli transaction calculate-min-fee \
    --tx-body-file tx.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

tx.raw command

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out $(cat payment.addr)+${total_balance}+"1 <TOKEN1POLICYID>.<TOKEN1ASSETNAME> + 1 <TOKEN2POLICYID>.<TOKEN2ASSETNAME>"  \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee ${fee} \
    --certificate-file pool.cert \
    --certificate-file deleg.cert \
    --out-file tx.raw

Balance & UTXO command (stays the same)

cardano-cli query utxo \
    --address $(cat 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}

Correct?

Don’t know if it likes the spaces around the + between the two tokens.

Otherwise, it looks good to me.

1 Like

Oh, and you have to substract the fee from the total balance after calculating it.

1 Like