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.
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?
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:
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.
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.
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.
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.
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