<h2>How to set the absolute fee</h2>
<p>The transaction fee is implicitly defined by the difference between the sum of input and the sum of output amounts.</p>
<pre><code>fee = Σ(inputs) - Σ(outputs)
</code></pre>
<p>Since you are building your transactions explicitly, you can set the exact transaction fee by defining the corresponding specific amounts of the outputs for the recipient(s) and the change output. As the weight of inputs and outputs is <a href="https://bitcoin.stackexchange.com/a/75124/5406">predictable</a>, you can calculate the appropriate fees by knowing the count and type of inputs and outputs in advance.</p>
<h2>Why it's a bad idea</h2>
<p>While your wallet can determine the input count during the transaction building, your users will not know in advance how many inputs it will take to fund their transaction. Since transactions get processed in order of their feerate rather than their absolute fee, the user will not be able to make an informed decision for an absolute fee without knowing the weight of the transaction. Per my experience, users get absolute fees wrong more often than not (most users even get feerates wrong), which leads to substantial support traffic with complaints about overpaying or underpaying. This is why withdrawal interfaces usually give predetermined choices (e.g. express, normal, thrifty) or take a feerate rather than an absolute fee.</p>
<p>If you want the recipient to pay the fee, you may want to consider using <code>subtractfeefromamount</code>.</p>

CC BY-SA 4.0
2021-02-05T03:20:44.363Z
Thanks for the reply! I did take a look at other Bitcoin online wallets and they do give predetemined choices, so that's what I'll be going with!
Stan Loona
CC BY-SA 4.0
2021-02-04T21:59:01.390Z
2021-02-04T22:04:52.393Z
2021-02-04T22:04:52.393Z
Murch
<p>I'm currently working on a personal project which is a small bitcoin exchange website, I've figured out how to create a raw transaction and broadcast it (createrawtransaction -&gt; fundrawtransaction -&gt; signrawtransactionwithwallet -&gt; sendrawtransaction).</p>
<p>There's a option in <a href="https://chainquery.com/bitcoin-cli/fundrawtransaction" rel="nofollow noreferrer">fundrawtransaction</a> which lets you set the fee but it's in BTC/kB. Are there any options on how to send the transaction specifying the final fee in satoshis? Or how do I know the final size of the transaction to calculate the fee? I want users to choose the fee in satoshis and not in BTC/kB.</p>
<p>I don't know if this has something to do but I'm using bech32 addresses. Thanks for your help!</p>

<bitcoin-core><transactions><transaction-fees><raw-transaction>
How to set a specific fee in satoshis per transaction?
Stan Loona
# How to set a specific fee in satoshis per transaction?

(Asked by: username_0 on 2021-02-04)

I'm currently working on a personal project which is a small bitcoin exchange website, I've figured out how to create a raw transaction and broadcast it (createrawtransaction -> fundrawtransaction -> signrawtransactionwithwallet -> sendrawtransaction).

There's a option in [fundrawtransaction](https://chainquery.com/bitcoin-cli/fundrawtransaction) which lets you set the fee but it's in BTC/kB. Are there any options on how to send the transaction specifying the final fee in satoshis? Or how do I know the final size of the transaction to calculate the fee? I want users to choose the fee in satoshis and not in BTC/kB.

I don't know if this has something to do but I'm using bech32 addresses. Thanks for your help!

**Tags:** bitcoin-core, transactions, transaction-fees, raw-transaction


---

## 1 answers

### Answer by username_1 on 2021-02-04. Score: 3 | Accepted answer

## How to set the absolute fee

The transaction fee is implicitly defined by the difference between the sum of input and the sum of output amounts.

```
fee = Σ(inputs) - Σ(outputs)

```

Since you are building your transactions explicitly, you can set the exact transaction fee by defining the corresponding specific amounts of the outputs for the recipient(s) and the change output. As the weight of inputs and outputs is [predictable](https://bitcoin.stackexchange.com/a/75124/5406), you can calculate the appropriate fees by knowing the count and type of inputs and outputs in advance.

## Why it's a bad idea

While your wallet can determine the input count during the transaction building, your users will not know in advance how many inputs it will take to fund their transaction. Since transactions get processed in order of their feerate rather than their absolute fee, the user will not be able to make an informed decision for an absolute fee without knowing the weight of the transaction. Per my experience, users get absolute fees wrong more often than not (most users even get feerates wrong), which leads to substantial support traffic with complaints about overpaying or underpaying. This is why withdrawal interfaces usually give predetermined choices (e.g. express, normal, thrifty) or take a feerate rather than an absolute fee.

If you want the recipient to pay the fee, you may want to consider using `subtractfeefromamount`.

> **Comments:**
> **username_0**: Thanks for the reply! I did take a look at other Bitcoin online wallets and they do give predetemined choices, so that's what I'll be going with!  

---

