<p>The miners fee is sum of inputs minus sum of outputs.</p>
<p>When you construct a transaction you make sure there is a difference between those two sums</p>
<hr />
<p>Here's a made up example, I want to buy a cup of coffee and I only have the Bitcoin equivalent of a million dollar bill (banknote) in my trouser pocket.</p>
<p>Transaction:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">Inputs</th>
<th style="text-align: right;">Outputs</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">60.00000</td>
<td style="text-align: right;">(to coffee shop)         0.00018</td>
</tr>
<tr>
<td style="text-align: right;"> </td>
<td style="text-align: right;">(change returned to me)  59.99981</td>
</tr>
</tbody>
</table>
</div>
<p>Sums:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">Inputs</th>
<th style="text-align: right;">Outputs</th>
<th style="text-align: right;">Difference</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">60.00000</td>
<td style="text-align: right;">59.99999</td>
<td style="text-align: right;">(fee for miner to collect) 0.00001</td>
</tr>
</tbody>
</table>
</div>
CC BY-SA 4.0
2022-12-29T05:46:29.373Z
>”The miners fee is sum of inputs minus sum of outputs. When you construct a transaction you make sure there is a difference between those two sums“ ⇒ So what happens if the sender only has really large inputs? Is the miner to assume they are allowed to take a large fee from their transactions if they make small transactions with big inputs? How is something like fee-per-byte determined if you might not have the right input to limit your input-output difference? Is there a limit on how big of a fee can be taken?
Poseidon
CC BY-SA 4.0
2022-12-29T15:39:10.227Z
You would create a change output back to your wallet - just like in real life. This is very common and done automatically by your wallet software. You might want to take a closer look at the bitcoin transaction model and the concept of UTXO (unspent transaction outputs).
sutterseba
CC BY-SA 4.0
2022-12-29T16:07:37.130Z
@Poseidon: Check out https://bitcoin.stackexchange.com/q/736/5406
Murch
CC BY-SA 4.0
2022-12-29T16:59:01.097Z
I added an example to clarify
RedGrittyBrick
CC BY-SA 4.0
2022-03-03T09:34:23.713Z
2022-12-29T16:58:46.943Z
2022-12-29T16:58:46.943Z
RedGrittyBrick
<p>I know that the way miners claim their fees are by factoring them in the BTC amount specified in the coinbase, which the protocol forces the max selectable value to be the current block reward + the total fees included from TXs in the block.</p>
<p>But how do people themselves specify what amount of the BTC should be spent on fees in their transactions? Is there a special output area that says to pay it to the miner, or how is it structured?</p>
<p>My question is, in literal concept, how are the fees chosen in a TX when constructing a tx manually.</p>

<transaction-fees>
How are fees specified in a TX?
bitcash complex
# How are fees specified in a TX?

(Asked by: username_0 on 2022-03-03)

I know that the way miners claim their fees are by factoring them in the BTC amount specified in the coinbase, which the protocol forces the max selectable value to be the current block reward + the total fees included from TXs in the block.

But how do people themselves specify what amount of the BTC should be spent on fees in their transactions? Is there a special output area that says to pay it to the miner, or how is it structured?

My question is, in literal concept, how are the fees chosen in a TX when constructing a tx manually.

**Tags:** transaction-fees


---

## 1 answers

### Answer by username_1 on 2022-03-03. Score: 2

The miners fee is sum of inputs minus sum of outputs.

When you construct a transaction you make sure there is a difference between those two sums

---

Here's a made up example, I want to buy a cup of coffee and I only have the Bitcoin equivalent of a million dollar bill (banknote) in my trouser pocket.

Transaction:

| Inputs | Outputs |
| --- | --- |
| 60.00000 | (to coffee shop) 0.00018 |
|  | (change returned to me) 59.99981 |

Sums:

| Inputs | Outputs | Difference |
| --- | --- | --- |
| 60.00000 | 59.99999 | (fee for miner to collect) 0.00001 |

> **Comments:**
> **username_2**: >”The miners fee is sum of inputs minus sum of outputs. When you construct a transaction you make sure there is a difference between those two sums“ ⇒ So what happens if the sender only has really large inputs? Is the miner to assume they are allowed to take a large fee from their transactions if they make small transactions with big inputs? How is something like fee-per-byte determined if you might not have the right input to limit your input-output difference? Is there a limit on how big of a fee can be taken?  
> **username_3**: You would create a change output back to your wallet - just like in real life. This is very common and done automatically by your wallet software. You might want to take a closer look at the bitcoin transaction model and the concept of UTXO (unspent transaction outputs).  
> **username_4**: @username_2: Check out https://bitcoin.stackexchange.com/q/736/5406  
> **username_1**: I added an example to clarify  

---

