Retiring pool, i'm trying to send back ada to yoroi

Hi guys, i’ve retired my pool, i get back the 500 ADA.
Yesterday tried to send back the ada from the stake address to my yoroi wallet, but i got this error:

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (BabbageOutputTooSmallUTxO [((Addr Mainnet (KeyHashObj (KeyHash "6cb070f430fd79ed65be702c7f019f7a21c17779a75be239bfc456b2")) (StakeRefBase (KeyHashObj (KeyHash "51eac07f8dec992e666a45f297c6081f0991722ec7e8968d517617d5"))),MaryValue (Coin 5039) (MultiAsset (fromList [])),NoDatum,SNothing),Coin 961130)]))])

this is the stake address: stake1u9g74srl3hkfjtnxdfzl997xpq0snytj9mr7395d29mp04grkt8r0
i’ve done a transaction with this size of lovelance: 1486886455, so i should be able to do it and pay the transaztion fee.
Can someone explain me why is not working?

I’ve just tried again removing the tx-out as suggested here:

but it gives me this: Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (AlonzoInBabbageUtxoPredFailure (ValueNotConservedUTxO (MaryValue (Coin 1487066455) (MultiAsset (fromList []))) (MaryValue (Coin 1487058732) (MultiAsset (fromList []))))))])

Greetings Simone, Apologies for the inconvenience. I’ve forwarded this to our development team to take a look at. One thing you can try in the meantime is to just be sure the wallet is in sync. You can do this by heading to Settings > Wallet > Resync, and retry. This could remedy the issue. Please let me know if it does not while I await their reply.

Thanks!

1 Like

So, that all has nothing to do with Yoroi, but with how you build the transaction with cardano-cli.

Without seeing the commands it’s a bit hard to guess what exactly went wrong there.

The first error is that one of the outputs was too small which is surprising if you want to move everything including the 500 ADA deposit over to the Yoroi wallet.

The second error is that the sum of the inputs is slightly different than the sum of the outputs. So, maybe you did not recalculate the output value after calculating the fee?

2 Likes

Here all the command that i use in order:

currentSlot=$(cardano-cli query tip --mainnet | jq -r '.slot')
echo Current Slot: $currentSlot
amountToSend=1485816455
echo amountToSend: $amountToSend
destinationAddress=addr1q946anf8fee9tajfw0h7ulh6r9935psa4uzh467zntx86uwj9jnglwap04ass6xzessaf3h38yagkd6l0nnwwj5f5knqd83llr
echo destinationAddress: $destinationAddress
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
    type=$(awk '{ print $6 }' <<< "${utxo}")
    if [[ ${type} == 'TxOutDatumNone' ]]
    then
        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}"
    fi
done < balance.out
txcnt=$(cat balance.out | wc -l)
echo Total available ADA balance: ${total_balance}
echo Number of UTXOs: ${txcnt}
cb69a180b10a2a7525dc73d0e24ae0edc71e7158149fa743a2b501bb779df913     0        1487066455 lovelace + TxOutDatumNone
TxHash: cb69a180b10a2a7525dc73d0e24ae0edc71e7158149fa743a2b501bb779df913#0
ADA: 1487066455
Total available ADA balance: 1487066455
Number of UTXOs: 1
cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out ${destinationAddress}+0 \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee 0 \
    --out-file tx.tmp
fee=$(cardano-cli transaction calculate-min-fee \
    --tx-body-file tx.tmp \
    --tx-in-count ${txcnt} \
    --tx-out-count 2 \
    --mainnet \
    --witness-count 1 \
    --byron-witness-count 0 \
    --protocol-params-file params.json | awk '{ print $1 }')
echo fee: $fee

fee: 172277

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

Change Output: 1077723

cardano-cli transaction build-raw \
    ${tx_in} \
    --tx-out ${destinationAddress}+${amountToSend} \
    --invalid-hereafter $(( ${currentSlot} + 10000)) \
    --fee ${fee} \
    --out-file tx.raw

On airgapped computer:

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

After i send the transaction with block producer.
I’m following the coincasew guide.

That you still use --tx-out-count 2 although you only have one output left will lead to a fee that is a little more than necessary.

You don’t even use what you are calculating here in:

You should use something like amountToSend=$((${total_balance}-${fee})) to calculate the correct amount that should go on the only output before building the transaction.

I am not a big fan of these copy and paste guides that help so little in understanding what is happening there.

If you just want to send everything on your pool address addr1q9ktqu85xr7hnmt9heczclcpnaazrsth0xn4hc3ehlz9dvj3atq8lr0vnyhxv6j972tuvzqlpxghytk8aztg65tkzl2sf5yvay to your Yoroi address addr1q946anf8fee9tajfw0h7ulh6r9935psa4uzh467zntx86uwj9jnglwap04ass6xzessaf3h38yagkd6l0nnwwj5f5knqd83llr, there is an even simpler way:

You just look up all UTxOs on the source address. The code you executed already did that, but you could also do a plain cardano-cli query utxo --mainnet --address addr1q9ktqu85xr7hnmt9heczclcpnaazrsth0xn4hc3ehlz9dvj3atq8lr0vnyhxv6j972tuvzqlpxghytk8aztg65tkzl2sf5yvay or just look it up on an explorer like https://adastat.net/addresses/addr1q9ktqu85xr7hnmt9heczclcpnaazrsth0xn4hc3ehlz9dvj3atq8lr0vnyhxv6j972tuvzqlpxghytk8aztg65tkzl2sf5yvay. All lead to the same result: There is a single UTxO that you want to spend: cb69a180b10a2a7525dc73d0e24ae0edc71e7158149fa743a2b501bb779df913#0

So, everything you have to do is:

cardano-cli transaction build --mainnet \
--tx-in cb69a180b10a2a7525dc73d0e24ae0edc71e7158149fa743a2b501bb779df913#0 \
--change-address addr1q946anf8fee9tajfw0h7ulh6r9935psa4uzh467zntx86uwj9jnglwap04ass6xzessaf3h38yagkd6l0nnwwj5f5knqd83llr \
--out-file tx.raw

That will just build the whole transaction including proper fees without all the manual steps.

That tx.raw file can then be signed on the air-gapped machine.

2 Likes

Thanks a lot!

1 Like