<blockquote>
<p>Does Alice pay more or does Bob get less? (the fee has to come from somebody)</p>
</blockquote>
<p>Alice pays more.</p>
<p>It works like this: Alice submits a transaction with inputs adding up to, for example, 0.016 BTC. This transaction  includes outputs totaling 0.015 BTC to Bob. The difference, in this example 0.001 BTC, would be the transaction fee in this case.</p>
<blockquote>
<p>The way to calculate the fee</p>
</blockquote>
<p>The fee of Bitcoin transactions is calculated on the size of the transaction, not the value being transacted. For each byte of your transaction, you are bidding a certain number of satoshi, known as the &quot;fee rate&quot; -- so for example, if you chose a 100 sat/byte fee rate, and your transaction is 600 bytes, then your transaction fee would be 600*100=60000 sat (0.0006 BTC).</p>
<p>You are bidding for space in a block. Because only a certain amount of transactions can go into each block, most miners will select the transactions with the highest satoshi per byte fee rate, because it is more profitable for them to collect these fees.</p>
<p>Technically you could choose a 0 sat/byte fee rate, making your transaction free of fees, but nowadays miners will probably not include your transaction in a block because they'd be losing money (and nodes will probably not propagate it), so your transaction will never confirm. However, it's still a valid transaction, and indeed, earlier in Bitcoin's history when transaction volume was much lower and block space wasn't so competitive, most transactions included 0 fees.</p>
<blockquote>
<p>I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and &quot;want&quot; to include a fee.</p>
</blockquote>
<p>The price of the transaction is completely irrelevant to the fees. Since it's by the size of your transaction... if your $10 USD transaction is very complicated and results in a large transaction, you may end up paying a hilariously large fee to have it confirmed. By contrast, if your $1M transaction is very simple and the transaction is very small, then the fees for that transaction will be low, despite it being a high value transaction.</p>
<blockquote>
<p>The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it. It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?</p>
</blockquote>
<p>The miner who mines the block that first includes your transaction gets your transaction fee. Let's say your transaction was included in block #123. The miner who mined block #123 receives your transaction fee.</p>

CC BY-SA 4.0
2021-01-26T16:30:53.687Z
Good answer. It would be great if you distinguished "fee" and "feerate", it's often a source of confusion when people talk about feerates but call it the fee, just like the absolute fee. Also note that most nodes run with the default `minRelayTxFeeRate` of 1 sat/vB, so they'll not add any transactions with feerates below that to their mempool and corollary also not relay it. If you wanted to pay less, you'd likely have to find a miner that accepts that and submit to them directly.
Murch
CC BY-SA 4.0
2021-01-26T17:48:38.757Z
@Prayank why edit it? that sentence is relevant to the answer.
ieatpizza
CC BY-SA 4.0
2021-01-26T14:18:01.610Z
2021-01-26T18:01:16.047Z
2021-01-26T18:01:16.047Z
ieatpizza
<p><strong>How is the fee specified?</strong></p>
<p>The transaction fee is paid by the sender.</p>
<p>Bitcoin transactions consist of three parts. The inputs specify which <em>unspent transaction outputs</em> (UTXOs) get consumed and satisfy the corresponding locking scripts, the outputs define which new UTXOs are created by the transaction per amounts and addresses, and the header keeps track of metadata like the version field, the locktime, the input and output counts.</p>
<p>The transaction fee is only specified implicitly, by the difference of the input amounts and output amounts:</p>
<pre><code>transaction fee = Σ(inputs) – Σ(outputs)
</code></pre>
<p><strong>How do miners collect fees?</strong></p>
<p>When a miner finds a valid block, they <a href="https://bitcoin.stackexchange.com/q/4571/5406">pay themselves</a> the block reward. The block reward consists of the block subsidy (new coins), and the fees of the transactions included in the block.<br />
When Bitcoin users submit transactions, the nodes on the network relay the transactions and collect them in their <em>mempools</em>, their queue of unconfirmed transactions. Miners select transactions for their block templates from their nodes' mempools. A block is limited to 4,000,000 <a href="https://bitcoin.stackexchange.com/q/53623/5406">weight units</a>, which translates to about 2,500 to 4,000 transactions, depending on the transactions' weights. Given the limit, miners prefer transactions higher feerates (fee per weight), since that will yield the greatest block reward.</p>
<p><strong>How do users pick fees to get confirmed?</strong></p>
<p>When users send transactions, they must consider how urgently they want their transactions to be confirmed. Depending on their choice, their wallet software estimates a feerate. As their wallet software <a href="https://bitcoin.stackexchange.com/q/32145/5406">picks</a> a set of inputs to fund the transaction, the wallet keeps track of the weight the inputs and outputs will incur, and allocates the absolute fee that results in the targeted feerate. As the transaction then queues, this fee functions as a bid for the necessary blockspace to include the transaction.</p>
<p>You may have noticed that the fee is not related to the payment's value at all. A transaction with one input and one output will cost the same whether you send $10 or $10M. The fee is purely a function of the weight of the transaction and the urgency of the user. This results in larger payments having a lower relative cost and Bitcoin's base layer being poorly suited for micropayments. The slow confirmations, high cost for micropayments, and scalability concerns provide some of the <a href="https://bitcoin.stackexchange.com/q/48283/5406">motivations</a> for the development of the Lightning Network, a second-layer instant payment system on-top of Bitcoin's base layer.</p>
<p>A main challenge for feerate estimation is that it's <a href="https://bitcoin.stackexchange.com/a/3911/5406">unpredictable</a> when the next block will be found and how many transactions will get queued until then. The probabilistic nature of mining and varying demand causes interesting <a href="https://bitcoin.stackexchange.com/q/99694/5406">dynamics for the global transaction queue</a>. Some of these problems can be sidestepped by issuing <a href="https://bitcoin.stackexchange.com/q/44510/5406">replaceable transactions</a> which can be reprioritized by overwriting them with transactions of bidding a higher fee. Note that most nodes will not relay transactions sent with feerates of less than 1 sat/vB.</p>

CC BY-SA 4.0
2021-01-26T19:27:05.390Z
so 1 Bitcoin is many many blocks? Finding a block is the same time every year, but just that every 4 years, the number of blocks double?
deeper-understanding
CC BY-SA 4.0
2021-01-26T19:53:04.300Z
I am also just interested in the range of percentage of fees... can it be 10%, 15%, 3% when you buy a coffee or when you send or sell $1 million worth of BTC?
deeper-understanding
CC BY-SA 4.0
2021-01-26T21:50:16.677Z
I'm not sure I understand what you mean with "1 Bitcoin is many many blocks". Blocks are found about every ten minutes, and every new block creates 6.25 fresh bitcoins at this time. Beyond that, each "piece" of bitcoin is tracked as a uniquely identifiable UTXO. I'll amend my text to address your question about relative fees.
Murch
CC BY-SA 4.0
2021-01-26T17:27:57.937Z
2022-07-03T13:14:10.017Z
2022-07-03T13:14:10.017Z
Murch
<p>I found out more and wanted to post what I found out:</p>
<ol>
<li><p>The sender pays the fee</p>
</li>
<li><p>The sender can choose how much fees to pay, but if the fee is low, then the transaction can sit there for a while before it can go through (nobody wants to process it), meaning that it can be 5 minutes or up to 72 hours or more. So for this reason, it seems you wouldn't want to buy a coffee and add a fee, when you can use a credit card and earn 2% cash instead. Also, I think nobody would like to buy a coffee and wait at the cash register for 5 or 10 minutes before they can finally drink the coffee.</p>
</li>
<li><p>The miner mines Bitcoin, and they can also process the transaction. If that transaction involved a lot of misc Bitcoin pieces, it will be bigger data size. The size means it will occupy their block, so they would like to process all the transaction with little data, but higher fee first.  Some wallets are said to automatically estimate what fee to pay so that your transaction can go through fast.</p>
</li>
</ol>

CC BY-SA 4.0
2021-01-26T16:13:53.420Z
2021-01-26T16:13:53.420Z
deeper-understanding
<p>I am reading the book Mastering Bitcoins 2nd Edition by O'Reilly, and it says:</p>
<blockquote>
<p>Alice buys a coffee from Bob's Cafe for $1.50, or 0.015 Bitcoin</p>
</blockquote>
<p>So Alice pays 0.015 Bitcoin, and Bob gets 0.015 Bitcoin, but there is a transaction fee, paid to the miner.</p>
<p>There are some questions:</p>
<ol>
<li>Does Alice pay more or does Bob get less?  (the fee has to come from somebody)</li>
<li><a href="https://en.bitcoin.it/wiki/Miner_fees" rel="nofollow noreferrer">The way to calculate the fee</a> seems to be a whole essay. Typically, what kind of percentage can the fee be, if it is a $1.5 coffee, or if somebody sends another person US$1 million dollar worth of Bitcoin, or if it is exchanging Bitcoin for US$1 million? But <a href="https://bitcoin.stackexchange.com/a/9899/114595">one person mentioned that it is voluntary</a> (even the link above said the spender &quot;may&quot; include a fee, suggesting they can choose not to), but who would want to pay a fee if they don't have to? I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and &quot;want&quot; to include a fee.</li>
<li>The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it.  It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?</li>
</ol>

<transaction-fees><mining-reward><blockspace-market>
How can transaction fees be explained in a simple way?
deeper-understanding
# How can transaction fees be explained in a simple way?

(Asked by: username_0 on 2021-01-26)

I am reading the book Mastering Bitcoins 2nd Edition by O'Reilly, and it says:

> Alice buys a coffee from Bob's Cafe for $1.50, or 0.015 Bitcoin

So Alice pays 0.015 Bitcoin, and Bob gets 0.015 Bitcoin, but there is a transaction fee, paid to the miner.

There are some questions:

1. Does Alice pay more or does Bob get less? (the fee has to come from somebody)
2. [The way to calculate the fee](https://en.bitcoin.it/wiki/Miner_fees) seems to be a whole essay. Typically, what kind of percentage can the fee be, if it is a $1.5 coffee, or if somebody sends another person US$1 million dollar worth of Bitcoin, or if it is exchanging Bitcoin for US$1 million? But [one person mentioned that it is voluntary](https://bitcoin.stackexchange.com/a/9899/114595) (even the link above said the spender "may" include a fee, suggesting they can choose not to), but who would want to pay a fee if they don't have to? I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and "want" to include a fee.
3. The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it. It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?

**Tags:** transaction-fees, mining-reward, blockspace-market


---

## 3 answers

### Answer by username_1 on 2021-01-26. Score: 3

> Does Alice pay more or does Bob get less? (the fee has to come from somebody)

Alice pays more.

It works like this: Alice submits a transaction with inputs adding up to, for example, 0.016 BTC. This transaction includes outputs totaling 0.015 BTC to Bob. The difference, in this example 0.001 BTC, would be the transaction fee in this case.

> The way to calculate the fee

The fee of Bitcoin transactions is calculated on the size of the transaction, not the value being transacted. For each byte of your transaction, you are bidding a certain number of satoshi, known as the "fee rate" -- so for example, if you chose a 100 sat/byte fee rate, and your transaction is 600 bytes, then your transaction fee would be 600\*100=60000 sat (0.0006 BTC).

You are bidding for space in a block. Because only a certain amount of transactions can go into each block, most miners will select the transactions with the highest satoshi per byte fee rate, because it is more profitable for them to collect these fees.

Technically you could choose a 0 sat/byte fee rate, making your transaction free of fees, but nowadays miners will probably not include your transaction in a block because they'd be losing money (and nodes will probably not propagate it), so your transaction will never confirm. However, it's still a valid transaction, and indeed, earlier in Bitcoin's history when transaction volume was much lower and block space wasn't so competitive, most transactions included 0 fees.

> I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and "want" to include a fee.

The price of the transaction is completely irrelevant to the fees. Since it's by the size of your transaction... if your $10 USD transaction is very complicated and results in a large transaction, you may end up paying a hilariously large fee to have it confirmed. By contrast, if your $1M transaction is very simple and the transaction is very small, then the fees for that transaction will be low, despite it being a high value transaction.

> The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it. It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?

The miner who mines the block that first includes your transaction gets your transaction fee. Let's say your transaction was included in block #123. The miner who mined block #123 receives your transaction fee.

> **Comments:**
> **username_2**: Good answer. It would be great if you distinguished "fee" and "feerate", it's often a source of confusion when people talk about feerates but call it the fee, just like the absolute fee. Also note that most nodes run with the default `minRelayTxFeeRate` of 1 sat/vB, so they'll not add any transactions with feerates below that to their mempool and corollary also not relay it. If you wanted to pay less, you'd likely have to find a miner that accepts that and submit to them directly.  
> **username_1**: @Prayank why edit it? that sentence is relevant to the answer.  

---

### Answer by username_2 on 2021-01-26. Score: 1

**How is the fee specified?**

The transaction fee is paid by the sender.

Bitcoin transactions consist of three parts. The inputs specify which *unspent transaction outputs* (UTXOs) get consumed and satisfy the corresponding locking scripts, the outputs define which new UTXOs are created by the transaction per amounts and addresses, and the header keeps track of metadata like the version field, the locktime, the input and output counts.

The transaction fee is only specified implicitly, by the difference of the input amounts and output amounts:

```
transaction fee = Σ(inputs) – Σ(outputs)

```

**How do miners collect fees?**

When a miner finds a valid block, they [pay themselves](https://bitcoin.stackexchange.com/q/4571/5406) the block reward. The block reward consists of the block subsidy (new coins), and the fees of the transactions included in the block.  
When Bitcoin users submit transactions, the nodes on the network relay the transactions and collect them in their *mempools*, their queue of unconfirmed transactions. Miners select transactions for their block templates from their nodes' mempools. A block is limited to 4,000,000 [weight units](https://bitcoin.stackexchange.com/q/53623/5406), which translates to about 2,500 to 4,000 transactions, depending on the transactions' weights. Given the limit, miners prefer transactions higher feerates (fee per weight), since that will yield the greatest block reward.

**How do users pick fees to get confirmed?**

When users send transactions, they must consider how urgently they want their transactions to be confirmed. Depending on their choice, their wallet software estimates a feerate. As their wallet software [picks](https://bitcoin.stackexchange.com/q/32145/5406) a set of inputs to fund the transaction, the wallet keeps track of the weight the inputs and outputs will incur, and allocates the absolute fee that results in the targeted feerate. As the transaction then queues, this fee functions as a bid for the necessary blockspace to include the transaction.

You may have noticed that the fee is not related to the payment's value at all. A transaction with one input and one output will cost the same whether you send $10 or $10M. The fee is purely a function of the weight of the transaction and the urgency of the user. This results in larger payments having a lower relative cost and Bitcoin's base layer being poorly suited for micropayments. The slow confirmations, high cost for micropayments, and scalability concerns provide some of the [motivations](https://bitcoin.stackexchange.com/q/48283/5406) for the development of the Lightning Network, a second-layer instant payment system on-top of Bitcoin's base layer.

A main challenge for feerate estimation is that it's [unpredictable](https://bitcoin.stackexchange.com/a/3911/5406) when the next block will be found and how many transactions will get queued until then. The probabilistic nature of mining and varying demand causes interesting [dynamics for the global transaction queue](https://bitcoin.stackexchange.com/q/99694/5406). Some of these problems can be sidestepped by issuing [replaceable transactions](https://bitcoin.stackexchange.com/q/44510/5406) which can be reprioritized by overwriting them with transactions of bidding a higher fee. Note that most nodes will not relay transactions sent with feerates of less than 1 sat/vB.

> **Comments:**
> **username_0**: so 1 Bitcoin is many many blocks? Finding a block is the same time every year, but just that every 4 years, the number of blocks double?  
> **username_0**: I am also just interested in the range of percentage of fees... can it be 10%, 15%, 3% when you buy a coffee or when you send or sell $1 million worth of BTC?  
> **username_2**: I'm not sure I understand what you mean with "1 Bitcoin is many many blocks". Blocks are found about every ten minutes, and every new block creates 6.25 fresh bitcoins at this time. Beyond that, each "piece" of bitcoin is tracked as a uniquely identifiable UTXO. I'll amend my text to address your question about relative fees.  

---

### Answer by username_0 on 2021-01-26. Score: 1

I found out more and wanted to post what I found out:

1. The sender pays the fee
2. The sender can choose how much fees to pay, but if the fee is low, then the transaction can sit there for a while before it can go through (nobody wants to process it), meaning that it can be 5 minutes or up to 72 hours or more. So for this reason, it seems you wouldn't want to buy a coffee and add a fee, when you can use a credit card and earn 2% cash instead. Also, I think nobody would like to buy a coffee and wait at the cash register for 5 or 10 minutes before they can finally drink the coffee.
3. The miner mines Bitcoin, and they can also process the transaction. If that transaction involved a lot of misc Bitcoin pieces, it will be bigger data size. The size means it will occupy their block, so they would like to process all the transaction with little data, but higher fee first. Some wallets are said to automatically estimate what fee to pay so that your transaction can go through fast.


---

