2

I am trying to build a transaction with a wallet that has 6 ADA. The transaction fee is 165721 lovelaces. So 6000000 - 165721 = 5827019 lovelaces. But when i try to send 5827019 lovelaces I get an error saying I can't build the transaction because the Minimum UTxO threshold: Lovelace 999978. Is it possible to send all my ADA or do I have have to leave a balance of at least 1 ADA?

Here is my build command

cardano-cli transaction build --alonzo-era --testnet-magic 1097911063 --change-address <change_addr> --tx-in <tx_in> --tx-out <recpt_addr>+5827019 --out-file <build_file>

3
  • 2
    Note: cardano-cli transaction build does have some issues, I find cardano-cli transaction build-raw is more reliable but need some extra work. You will need to calculate fees manually and add another --tx-out for the change. Commented Jun 16, 2022 at 5:43
  • Additiionally, if you use the cardano-cli transaction build-raw command, you can specify exactly the fee amount you wish to pay, and as long as it is above the minimum (which itself is estimated by the calculate-min-fee subcommand), the tx will be valid. Use this if you wish to create a transaction without change.
    – zhekson
    Commented Jun 17, 2022 at 14:23
  • If you are trying to send all to one address, just put that address in the --change-address and remove the --tx-out line. Commented Nov 7, 2022 at 7:13

4 Answers 4

2

The problem is that your fee is probably not exactly 165721.

  • You have 6000000 lovelace
  • You want to send 5827019 lovelace to recpt_addr
  • The fee is something like 165721 but not exactly (probably less)
  • Some lovelace are left and the command tries to send them to change_addr

You can inspect the transaction using cardano-cli transaction view --tx-body-file <build_file> to see the problem, then you can adjust your command params accordingly.

Maybe it would also work if you simply set the change address to the same address as the recipient:

  • --change-address <recpt_addr>
0

Cli commands to send all ada from an address to another :

cardano-cli transaction build-raw \
--tx-in a61c02<...>8848#0 \
--tx-out DdzFF<...>v2mEoo+2061351 \
--invalid-hereafter 000000 \
--fee 172233 \
--out-file tx.raw 

cardano-cli transaction calculate-min-fee \
--tx-body-file tx.raw \
--tx-in-count 1 \
--tx-out-count 1 \
--witness-count 1 \
--byron-witness-count 0 \
--mainnet \
--protocol-params-file ../../protocol.json

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

cardano-cli transaction submit \
--tx-file tx.signed \
--mainnet
0

As George and eddex mentioned, you should use the change field as your sole output. Since you are using the build endpoint rather than build-raw, and your input doesn't carry any tokens/NFTs, you don't need to worry about the fee either. Your build command should look like this:

cardano-cli transaction build $MAGIC \
  --tx-in <tx_in>                    \
  --change-address <recpt_addr>      \
  --out-file <build_file>

Sign and submit, and that's it!

0

I simply used build-raw command to send all ADA from first wallet to second. Here --tx-out-count will be 1 only. As there will be only one recipient

cardano-cli transaction calculate-min-fee \
 --tx-body-file tx.raw \
 --tx-in-count 1 \
 --tx-out-count 1 \
 --witness-count 1 \
 --byron-witness-count 0 \
 --mainnet \
 --protocol-params-file params.json

Command to build raw transaction

cardano-cli transaction build-raw \
 --tx-in <txn hash>#0 \
 --tx-out $(cat recipient.addr)+<all ada balance> \
 --invalid-hereafter 0 \ 
 --fee 0 \ 
 --out-file tx.raw

calculate min fee and manually calculate remaining ADA balance. Transaction with Fees

 cardano-cli transaction build-raw \
 --tx-in <txn hash>#0 \
 --tx-out $(cat recipient.addr)+<remaining ada balance>  \
 --invalid-hereafter $(( ${currentSlot} + 10000)) \
 --fee <Fee> \
 --out-file tx.raw

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.