Cardano-cli transaction submit error

Does anyone know what this particular error means please?

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (BabbageOutputTooSmallUTxO [((Addr Testnet (KeyHashObj (KeyHash "83183887eafd125cfb2002f977ea0967df37b98bdcc65500797caef0")) (StakeRefBase (KeyHashObj (KeyHash "154610e30b81988257fc98babb1f854dfb3d3910135f0847f993d6de"))),Value 175401 (fromList []),NoDatum,SNothing),Coin 978370),((Addr Testnet (KeyHashObj (KeyHash "06784446912230dffc24c446407dd7e29a4622de9fd13b5d240eea3d")) StakeRefNull,Value 175401 (fromList []),NoDatum,SNothing),Coin 857690)])),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 0 (fromList [])) (Value 526379 (fromList []))))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (BadInputsUTxO (fromList [TxIn (TxId {_unTxId = SafeHash "a8aee1922a07592941da9c04de801b7b4324846665215b57b91fa240c95d3639"}) (TxIx 0)]))))])

1 Like

There are three errors:

You have three outputs that do not contain the minimal amount of tADA.

That’s much too small. It’s only 0.17 ADA and you need at least around 1 ADA (if it’s an output without native tokens).

Additionally, the sum of your inputs and the sum of your outputs plus fee do not match.

As far as I can see, your inputs are empty.

But you try to spend 0.5 ADA.

That’s probably why your inputs are empty. The input UTxO is not okay. Did you perhaps already spend it?

Thank you for such a detailed response. According to Cardanoscan There’s still 2 ADA in the wallet so I will try to increase the minimum amount to 1ADA and see what happens.

Now I am getting this error…
Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 0 (fromList [])) (Value 5000000 (fromList []))))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (BadInputsUTxO (fromList [TxIn (TxId {_unTxId = SafeHash "a8aee1922a07592941da9c04de801b7b4324846665215b57b91fa240c95d3639"}) (TxIx 0)]))))])

It’s still ValueNotConservedUTxO with trying to spend 5 ADA, while the input is 0 because of BadInputsUTxO.

As far as I can see on Cardanoscan, the input should be okay. You received 2 ADA in https://preprod.cardanoscan.io/transaction/a8aee1922a07592941da9c04de801b7b4324846665215b57b91fa240c95d3639?tab=utxo and they also seem to be still unspent.

Are you really submitting the transaction to the Preprod network and not to Preview or Mainnet?

But it won’t work anyway: You cannot spend 5 tADA if your input are only 2 tADA.

Usually, your inputs have quite a bit more than you want to send. Then, you add one or more outputs to where you want to send. And then you add another (change) output to your own address that gets the rest: inputs minus other outputs minus fees.

cardano-cli transaction build (not build-raw) will calculate fee and change automatically if you add a --change-address parameter.

Or are you using something else to build the transaction?

Here are the commands I am using:

Command #1

cardano-cli transaction build-raw \
--tx-in a8aee1922a07592941da9c04de801b7b4324846665215b57b91fa240c95d3639#0 \
--tx-out addr_test1qzp3swy8at73yh8myqp0jal2p9na7dae30wvv4gq0972auq4gcgwxzupnzp90lych2a3lp2dlv7njyqntuyy07vn6m0q0mr7rm+1500000 \
--tx-out addr_test1vqr8s3zxjy3rphluynzyvsra6l3f533zm60azw6ays8w50g374zzk+"1500000 lovelace" \
--fee 2000000 \
--out-file ./_account/tx/tx.draft

Command #2

cardano-cli transaction sign \
--tx-body-file ./_account/tx/tx.draft \
--signing-key-file ./_account/keys/payment.skey  \
--testnet-magic $CARDANO_NODE_MAGIC \
--out-file ./_account/tx/tx.signed

Command #3

cardano-cli transaction submit \
--tx-file ./_account/tx/tx.signed \
--testnet-magic $CARDANO_NODE_MAGIC

You have an input of 2 000 000 Test Lovelace and try to spend 1 500 000 + 1 500 000 + 2 000 000 = 5 000 000 Test Lovelace. That can never work.

Also: Why are you writing "1500000 lovelace" on the second output? I have never seen that. Though it seems to be accepted and just mean the same as just 1500000.

And: 2000000 fee definitely saves you the hassle of calculating the fee, since it is more than enough, but also very generous to the pool operators. You won’t want to pay 2 ADA transaction fee for every single transaction.

The guides using build-raw usually also tell you the quite complicated steps to calculate the fee. Or, as said, use build instead of build-raw and --change-address to do it automatically.

To what value is $CARDANO_NODE_MAGIC set? And on what network does your cardano-node run?

You’ll have to forgive me, I am a complete noob at this and have practically no idea what I’m doing.

$CARDANO_NODE_MAGIC is set to 2

I believe it’s running on the preview network if I’m not mistaken. I am using https://demeter.run to test the code I am using.

Would you be able to help me structure the build query that you said as I’m not sure what way it’s supposed to look like. Thank you so much for your help

That already hints at a problem. The magic for Preprod (where your input UTxO lives) would be 1.

Sorry, not familiar with demeter.run up to now. Can you set the network there somewhere?

You’d first need a bit more tADA, so that we have enough to send away and also keep some change for ourselves.

Thankfully, your address already got a bit more during the past hour, as far as I can see. You can always check what UTxOs you could use on an address with cardano-cli query utxo.

The cardano-cli transaction build command would look roughly like:

cardano-cli transaction build --testnet-magic 1 \
--tx-in a8aee1922a07592941da9c04de801b7b4324846665215b57b91fa240c95d3639#0 \
--tx-in a8af6208e0e421a4e9201e7294354ca0d10282f5e1e73c4ca7bcd88cf9cfdc5f#0 \
--tx-out addr_test1qzp3swy8at73yh8myqp0jal2p9na7dae30wvv4gq0972auq4gcgwxzupnzp90lych2a3lp2dlv7njyqntuyy07vn6m0q0mr7rm+1500000 \
--change-address addr_test1vqr8s3zxjy3rphluynzyvsra6l3f533zm60azw6ays8w50g374zzk \
--out-file tx.unsigned

I have taken a second input that according to Cardanoscan should contain another 50 tADA.
There’s only one --tx-out with 1.5 tADA going to the address you were trying to send to earlier.
The --change-address says that the whole rest (a bit more than 50 tADA) should go back to a new UTxO on your own address.
That should be it.

I tried to change the node to the preprod network and ran your command and got this error

cardano-cli: HandshakeError (Refused NodeToClientV_13 "version data mismatch: NodeToClientVersionData {networkMagic = NetworkMagic {unNetworkMagic = 2}} /= NodeToClientVersionData {networkMagic = NetworkMagic {unNetworkMagic = 1}}")

Are you able to run the command? Does it work for you? I just think I’m doing something wrong.

Your UTxOs definitely are on Preprod and the network magic for Preprod definitely is 1. The command I gave you uses --testnet-magic 1.

I get the same error as you.

By default, demeter.run creates a workspace that is connected to the Preview network. You have to change that. And as far as I can see, you can only select Preprod on a new workspace. I just tried updating my workspace to use Preprod, but it still throws the same error as if it still runs on Preview.

If I create a new workspace and select Preprod from the beginning my command goes through.

Oh right ok I will try that now and get back to you, thank you very much

That worked thank you so much!

I’m using a code that runs queries to the cli and now I am getting this error

Command failed: transaction submit Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (BabbageOutputTooSmallUTxO [((Addr Testnet (KeyHashObj (KeyHash "83183887eafd125cfb2002f977ea0967df37b98bdcc65500797caef0")) (StakeRefBase (KeyHashObj (KeyHash "154610e30b81988257fc98babb1f854dfb3d3910135f0847f993d6de"))),Value 902189 (fromList []),NoDatum,SNothing),Coin 978370)])),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 1073190 (fromList [(PolicyID {policyID = ScriptHash "9c8e9da7f81e3ca90485f32ebefc98137c8ac260a072a00c4aaf142d"},fromList [(4d657368546f6b656e,1000000)])])) (Value 1073190 (fromList [])))))])

You scan the error messsage from the beginning. First come a few unimportant wrappers – ShelleyTxValidationError, ApplyTxError, …

The first interesting thing is:

It is again that one of your outputs is not big enough. After that, details concerning the error follow. First it shows what was the target address, but separated as payment key hash and stake key hash. Then, the actual value that was too small: Value 902189 and (I think) the minimum that it should have been Coin 978370.

That’s again a second error. In this case, the value in your inputs is (Value 1073190 (fromList [(PolicyID {policyID = ScriptHash "9c8e9da7f81e3ca90485f32ebefc98137c8ac260a072a00c4aaf142d"},fromList [(4d657368546f6b656e,1000000)])])), but your outputs are just (Value 1073190 (fromList [])). So, the ADA value is okay (except for the too small of the other error), but you have some tokens in your inputs that have to go somewhere.

All amounts have to be balanced. Sum of inputs has to be exactly the same as sum of outputs plus fee, also for native tokens. And, unfortunately, cardano-cli does not balance native tokens to the --change-address automatically, so you have to give a manual output to your own address if you want to keep them.

Mints and burns, withdrawals from the stake address, and the stake delegation and pool registration deposits also modify this balance. So, it’s actually: (inputs plus mints plus withdrawals plus returned delegation deposits) has to be exactly (outputs plus fee plus burns plus paid delegation or registration deposits).

Oh, you’re on it with @Alexd1985 in the other thread.

The --tx-ins are different for each transaction. After you have spent one, you have to select new unspent ones from your cardano-cli query utxo.

In your case, it would probably be: Take the UTxO you got from the buyer, mint the NFT, send them the NFT (and al tokens they may have sent you accidentally) with something like 2 ADA accompanying them in a --tx-out, and put the rest (which is the payment for the NFT) in --change-address to one of your own addresses (either the same you are using here or another wallet of yours).

If they sent to little to pay: Send them a refund. If it is too little to send a refund: Abort and maybe do it manually if they complain.

1 Like

Ok thank you for the detailed response, I truly appreciate it. I understand what you’re saying, my problem is I am simply not qualified enough yet to write the code to be able to do what you suggested unfortunately.

Two possibilities: we continue and you learn or you find someone to write it for you.

Which language do you want to use? Do you know any programming language already that you would be comfortable with?

Yeah I’m trying to learn and you and Alex are kind enough to help me, which I really do appreciate. I am a javascript developer by nature so anything along those lines would be great, I am learning how to use the cardano-cli and also I am just learning how to use typescript. Although typescript is just an off shoot of javascript so it’s not that difficult