<p>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 &quot;<code>--witness-override 2</code>&quot; if you know you will be signing it with 2 signatures and it will give an accurate fee.</p>

CC BY-SA 4.0
2022-01-02T22:09:20.667Z
2022-01-02T22:09:20.667Z
noone392
<p>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.</p>
<pre><code>cardano-cli query utxo \
--address $(cat payment.addr) \
--mainnet
</code></pre>
<p>grab all the utxo's and add them as tx-in as you normally would. You can have multiple in and out.</p>
<p>If it is all going to one place use --change-address. It will send whatevers left over after the fee to that address.</p>
<pre><code>cardano-cli transaction build \
--tx-in a-utxo#1 \
--tx-in another-utxo#0 \
--change-address &lt;to-addr&gt; \
--witness-override 1 \
--out-file tx.unsigned \
--alonzo-era \
--mainnet
</code></pre>
<p>It will print the fee. Witness is the number of keys needed for signing. 1 if it's just sending ada somewhere.</p>
<p>cold machine-</p>
<pre><code>cardano-cli transaction sign \
--tx-body-file tx.unsigned \
--signing-key-file payment.skey \
--mainnet \
--out-file tx.signed
</code></pre>
<p>-online submit</p>
<pre><code>cardano-cli transaction submit \
--tx-file tx.signed \
--mainnet
</code></pre>

CC BY-SA 4.0
2022-01-04T15:27:30.707Z
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
CC BY-SA 4.0
2022-01-03T14:58:40.617Z
2022-01-03T15:04:24.993Z
2022-01-03T15:04:24.993Z
WCat
<p>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.</p>
<p>You can also use &quot;cardano-cli transaction build&quot; 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.</p>
<p>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).</p>

CC BY-SA 4.0
2022-01-02T21:34:27.210Z
2022-01-02T21:34:27.210Z
George - APEX Stake Pool
<p>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.</p>
<p>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:</p>
<p>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</p>
<p>And fill in the correct #'s for the various parameters above. This will give you the exact fee.</p>
<p>Finally, go back and edit your draft TX with the final numbers so that everything balances out.</p>

CC BY-SA 4.0
2022-01-03T12:40:25.613Z
2022-01-03T12:40:25.613Z
Tygar Pool
<p>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.</p>
<p>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:</p>
<pre><code>Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (UtxoFailure (FeeTooSmallUTxO (Coin 169593) (Coin 168185))))])
</code></pre>
<p>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?</p>
<p>EDIT:
I can't actually submit this transaction at all, because when I try to change it to &quot;169593&quot; 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?</p>
<pre><code>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
</code></pre>
<p>face address of course</p>

<cardano-cli><transaction><fee>
submitting transaction FeeTooSmallUTxO
# submitting transaction FeeTooSmallUTxO

(Asked by: username_0 on 2022-01-02)

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

**Tags:** cardano-cli, transaction, fee

---

## 4 answers

### Answer by username_0 on 2022-01-02. Score: -1 | Accepted answer

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.


---

### Answer by username_1 on 2022-01-03. Score: 1

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) \
--mainnet

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  \
--witness-override 1 \
--out-file tx.unsigned \
--alonzo-era \
--mainnet

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 \
--mainnet

> **Comments:**
> **username_0**: 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  

---

### Answer by username_2 on 2022-01-02. Score: 1

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).


---

### Answer by username_3 on 2022-01-03. Score: 0

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.


---

