Can't make transaction for registering stake address (BadInputsUTxO)

Hello everyone, I’m very new to Cardano but I’m an experienced Linux Administrator and very excited to be part of this community.
I’m using more or less official and up to date documentation for the setup of my pool:

I’m using last version I build yesterday

cardano-node --version
cardano-node 1.26.1 - linux-x86_64 - ghc-8.10

I made this little script which is handy as I’m stuck at the submit phase :

cardano-cli transaction build-raw --tx-in b64ae44e1195b04663ab863b62337e626c65b0c9855a9fbb9ef4458f81a6f5ee#1 --tx-out $(cat paymentwithstake.addr)+0 --invalid-hereafter 0 --fee 0 --out-file /tmp/tx.raw --certificate-file stake.cert
ttl=$(expr $(cardano-cli query tip --mainnet|jq .slot) + 400)
fee=$(cardano-cli transaction calculate-min-fee --tx-body-file /tmp/tx.raw --tx-in-count 1 --tx-out-count 1 --witness-count 2 --byron-witness-count 0 --mainnet --protocol-params-file conf/protocol.json|awk '{print $1}')
change=$(expr 505000000 - 2000000 - $fee)
cardano-cli transaction build-raw --tx-in b64ae44e1195b04663ab863b62337e626c65b0c9855a9fbb9ef4458f81a6f5ee#1 --tx-out $(cat paymentwithstake.addr)+$change --invalid-hereafter $ttl --fee $fee --out-file /tmp/tx.raw --certificate-file stake.cert
cardano-cli transaction sign --tx-body-file /tmp/tx.raw --signing-key-file ../common/keys/payment.skey --signing-key-file ../common/keys/stake.skey --mainnet --out-file /tmp/tx.signed
cardano-cli transaction submit --tx-file /tmp/tx.signed --mainnet

Error is :

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraMary (ApplyTxError [LedgerFailure (UtxowFailure (UtxoFailure (BadInputsUTxO (fromList [TxInCompact (TxId {_unTxId = SafeHash “b64ae44e1195b04663ab863b62337e626c65b0c9855a9fbb9ef4458f81a6f5ee”}) 1])))),LedgerFailure (UtxowFailure (UtxoFailure (ValueNotConservedUTxO (Value 0 (fromList )) (Value 505000000 (fromList )))))])

IOHK zendesk tells that these errors are related to a bad calculation of values, but I can’t find the error here, all values look correct (I’ve been searching for several hours with no luck). For instance in my payment address I have 505000000 lovelace, which gives around 178525 fee and I do (505000000 - 2000000 - 178525) as value to append to the --tx-out payment address.

Can anybody kindly help ? :slight_smile:
Thanks in advance,

It looks like the --tx-in does not exist on the blockchain, so you might want to check that transaction ID: https://explorer.cardano.org/en/no-search-results?query=b64ae44e1195b04663ab863b62337e626c65b0c9855a9fbb9ef4458f81a6f5ee

You can use cardano-cli query utxo to list the unspent transactions at an address.

2 Likes

A reason for the TX not existing could be that you are not fully synced.
So the TX may exist but your local server just doesn’t know about it. Make sure your TIP is in sync whith the most recent from the network.

Ok my understanding of --tx-in and --tx-out values was completely wrong. Here the reason in case noobs like me find this thread : :slight_smile:
–tx-in has to be the Hash ID of your payment account, as returned by command “cardano-cli query uxto”. So both tx-in and tx-out refer to the same address.
Thank you for your answers :relaxed: