So I have a basic script that attempts to transfer everything from 1 address to another. In order to correctly conserve and to spend the minimum fee, I just build a transaction that uses 100% of the lovelace and let the build command tell me how much I am short, then rebuild the transaction - the fee from the error before.

But that stopped working for some reason. In my current example, the build command says I am short by 168185, then I rebuild minus that fee, and it works fine. I sign, and go to submit and I get this strange error showing my being just a tiny bit short:

Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 169593) (Coin 168185))))])

My question, is there a way to know the min fee without going through multiple iterations? and why is this fee different then the one from the build command?

EDIT: I can't actually submit this transaction at all, because when I try to change it to "169593" then the change output of 1408 doesn't meet the minimum utxo threshold for the change output. how can these two be calculated differently? Do I need to build raw and specify the fee explicitly of the higher amount?

Command failed: transaction build  Error: The transaction does balance in its use of ada, however the net balance does not meet the minimum UTxO threshold.
Balance: Lovelace 1408
Offending output (change output): addraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 1408 lovelace

face address of course

4 Answers 4


You should be able to create a transaction draft where you should specify a fee of 200000 lovelace (to have the same transaction size as the final transaction), then estimate the fees, and create the final transaction.

You can also use "cardano-cli transaction build" command and you don't need to calculate the transaction fees or build the transaction 2 times, you only build it once, sign it and submit it.

In case the change is smaller than 1 ADA, the only way to do the transaction without consuming another UTxO is to pay a higher fee for the transaction (add the change to the fee) or to send a higher amount to the destination address than what you wanted to send (add it to the output instead of paying it as a fee).


If you want to send everything in a wallet the new way that calculates the fee and adds ttl you can query for all the utxo's in the wallet.

cardano-cli query utxo \
--address $(cat payment.addr) \

grab all the utxo's and add them as tx-in as you normally would. You can have multiple in and out.

If it is all going to one place use --change-address. It will send whatevers left over after the fee to that address.

cardano-cli transaction build \
--tx-in a-utxo#1 \
--tx-in another-utxo#0 \
--change-address <to-addr> \
--witness-override 1 \
--out-file tx.unsigned \
--alonzo-era \

It will print the fee. Witness is the number of keys needed for signing. 1 if it's just sending ada somewhere.

cold machine-

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

-online submit

cardano-cli transaction submit \
--tx-file tx.signed \
  • 1
    Thanls for the complete example, this was exactly what i did nearly when I got the error! The issue was the number of signatures differed from the witness override
    – noone392
    Jan 4, 2022 at 15:27

Fees are variable - You cannot depend on them being the same for every transaction. Things such as changing the number of signing witnesses, or number of receivers, can make fees adjust.

To determine the correct fee, first create a draft TX and just use a dummy ada amount for the txout and txin parameters, such as 0, and then run:

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

And fill in the correct #'s for the various parameters above. This will give you the exact fee.

Finally, go back and edit your draft TX with the final numbers so that everything balances out.


The build command will differ from the amount when submitted from the signatures. So the problem is that the cost goes up with each signature. You can include this estimate by using the "--witness-override 2" if you know you will be signing it with 2 signatures and it will give an accurate fee.

Your Answer

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

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