<p>This number could be much more easily collected by reading out the total fees collected in a block and dividing it by the count of transactions in that block (deducting one for the coinbase), then translating the resulting average fee (BTC) to a USD amount.</p>
<hr />
<p>However, I'm going to offer a frame challenge. I do not consider “average fee per transaction (USD)” a useful metric.</p>
<p>First of all, it would be more meaningful, if the data were collected as “average fee per transaction (BTC)” as it would remove the overlying effect of the current exchange rate from the blockspace demand situation. Secondly, the fees shift wildly over the course of the day and week, so how useful is an average even? If you want to pay less, you can get away with the minimum feerate, if you are fine with waiting for a day ~12h. So it should be cast as “average fee to get confirmation within what time”? Thirdly, a transaction that pays 100 recipients, a transaction with a single recipient, and a transaction consolidating two hundred inputs in a self-send are interpreted all the same for the calculation of this figure. If you e.g. consider the four <a href="https://bitcoin.stackexchange.com/a/60183/5406">example blocks shown here</a>, you would get wildly different average fees—but mostly because users are trying to achieve wildly different things. Fourthly, transactions pay for blockspace, but the average value of payments on Bitcoin has increased by magnitudes over the project's existence. How comparable are costs per transaction over the years, when it meant sending $1 in average a decade ago and now the average payment is more than $10,000?</p>
<p>What you're trying to express with that metric? Is it a measure of how expensive it is currently to purchase blockspace? That's just the current feerate. Is it a measure of how expensive it is to transfer a certain amount of value? That depends on the user's UTXO pool and their urgency, whether they're sending to a single recipient or batching payments.</p>
<p>Perhaps it would be more interesting to offer figures on what the cost of getting a specific transaction confirmed in various timeframes would be. E.g. a transaction with one P2WPKH input and two P2WPKH outputs is 140.5 vB, and present what it costs to get that confirmed within the next hour vs the next day.</p>

CC BY-SA 4.0
2022-10-05T17:34:08.743Z
2022-10-05T17:43:45.587Z
2022-10-05T17:43:45.587Z
Murch
<blockquote>
<p>I know that the fee is calculated in this way: fee = feerate * tx_size</p>
</blockquote>
<p>Perhaps the sites you mention are calculating the actual fee paid: sum of input amounts minus sum of output amounts.</p>

CC BY-SA 4.0
2022-10-01T09:40:45.640Z
2022-10-01T13:43:44.770Z
2022-10-01T13:43:44.770Z
RedGrittyBrick
<p>The Blockchain is public. You can query and analyze all or part of it by running your own node. That would eliminate the unanswered questions about how the explorer APIs you're using define their calculation bases</p>
<p>More importantly, fees are Bitcoin amounts, not dollar amounts. Expressing fees in dollar amounts is complicated by the volatility of the dollar per Bitcoin exchange rate. That is, for a 3-month average, an accurate dollar estimate can only be calculated by knowing the point-in-time exchange rate for every single block in the period</p>
<p>As far as I know, there are no free public sources of block-by-block dollar per Bitcoin exchange rates</p>
<p>The Bitcoin transaction fee is not explicitly recorded. As the @RedGrittyBrick response says, the Bitcoin transaction fee is the sum of the output amounts subtracted from the sum of the input amounts. Note that the input amounts are not stored in the spending transaction. They are discovered by retrieving the amount from the transaction output being spent by each transaction input</p>

CC BY-SA 4.0
2022-10-05T14:29:41.557Z
2022-10-05T14:29:41.557Z
Louis Thompson
<p>We are creating a cryptocurrency analytics website and I was wondering how one can calculate the average transaction fee for Bitcoin. For example, like on these three sources.</p>
<p><a href="https://www.blockchain.com/charts/fees-usd-per-transaction" rel="nofollow noreferrer">https://www.blockchain.com/charts/fees-usd-per-transaction</a>
<a href="https://ycharts.com/indicators/bitcoin_average_transaction_fee" rel="nofollow noreferrer">https://ycharts.com/indicators/bitcoin_average_transaction_fee</a>
<a href="https://bitinfocharts.com/comparison/bitcoin-transactionfees.html#3m" rel="nofollow noreferrer">https://bitinfocharts.com/comparison/bitcoin-transactionfees.html#3m</a></p>
<p>They indicate that currently the average BTC transaction fee is $1.079, but when I try to calculate it myself I don't get the same result.</p>
<p>I know that the fee is calculated in this way: <strong>fee = feerate * tx_size</strong></p>
<p>So I get the rates either from here (<a href="https://api.blockchain.info/mempool/fees" rel="nofollow noreferrer">https://api.blockchain.info/mempool/fees</a>) or here (<a href="https://bitcoinfees.earn.com/api/v1/fees/recommended" rel="nofollow noreferrer">https://bitcoinfees.earn.com/api/v1/fees/recommended</a>) and multiply them by the average tx_size of 225 bytes.</p>
<p>However, I either get 70 cents or over $4 depending on what API I use, not $1.079 like in the examples above. What am I doing wrong? Or do those websites above use some other values for calculations?</p>
<p>Thanks a lot and have a great weekend!</p>

<transactions><transaction-fees><transaction-weight>
Trying to calculate the average fee per tx, but can't get the right value
buckwhitzer
# Trying to calculate the average fee per tx, but can't get the right value

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

We are creating a cryptocurrency analytics website and I was wondering how one can calculate the average transaction fee for Bitcoin. For example, like on these three sources.

<https://www.blockchain.com/charts/fees-usd-per-transaction>
<https://ycharts.com/indicators/bitcoin_average_transaction_fee>
<https://bitinfocharts.com/comparison/bitcoin-transactionfees.html#3m>

They indicate that currently the average BTC transaction fee is $1.079, but when I try to calculate it myself I don't get the same result.

I know that the fee is calculated in this way: **fee = feerate \* tx\_size**

So I get the rates either from here (<https://api.blockchain.info/mempool/fees>) or here (<https://bitcoinfees.earn.com/api/v1/fees/recommended>) and multiply them by the average tx\_size of 225 bytes.

However, I either get 70 cents or over $4 depending on what API I use, not $1.079 like in the examples above. What am I doing wrong? Or do those websites above use some other values for calculations?

Thanks a lot and have a great weekend!

**Tags:** transactions, transaction-fees, transaction-weight


---

## 3 answers

### Answer by username_1 on 2022-10-05. Score: 2 | Accepted answer

This number could be much more easily collected by reading out the total fees collected in a block and dividing it by the count of transactions in that block (deducting one for the coinbase), then translating the resulting average fee (BTC) to a USD amount.

---

However, I'm going to offer a frame challenge. I do not consider “average fee per transaction (USD)” a useful metric.

First of all, it would be more meaningful, if the data were collected as “average fee per transaction (BTC)” as it would remove the overlying effect of the current exchange rate from the blockspace demand situation. Secondly, the fees shift wildly over the course of the day and week, so how useful is an average even? If you want to pay less, you can get away with the minimum feerate, if you are fine with waiting for a day ~12h. So it should be cast as “average fee to get confirmation within what time”? Thirdly, a transaction that pays 100 recipients, a transaction with a single recipient, and a transaction consolidating two hundred inputs in a self-send are interpreted all the same for the calculation of this figure. If you e.g. consider the four [example blocks shown here](https://bitcoin.stackexchange.com/a/60183/5406), you would get wildly different average fees—but mostly because users are trying to achieve wildly different things. Fourthly, transactions pay for blockspace, but the average value of payments on Bitcoin has increased by magnitudes over the project's existence. How comparable are costs per transaction over the years, when it meant sending $1 in average a decade ago and now the average payment is more than $10,000?

What you're trying to express with that metric? Is it a measure of how expensive it is currently to purchase blockspace? That's just the current feerate. Is it a measure of how expensive it is to transfer a certain amount of value? That depends on the user's UTXO pool and their urgency, whether they're sending to a single recipient or batching payments.

Perhaps it would be more interesting to offer figures on what the cost of getting a specific transaction confirmed in various timeframes would be. E.g. a transaction with one P2WPKH input and two P2WPKH outputs is 140.5 vB, and present what it costs to get that confirmed within the next hour vs the next day.


---

### Answer by username_2 on 2022-10-01. Score: 0

> I know that the fee is calculated in this way: fee = feerate \* tx\_size

Perhaps the sites you mention are calculating the actual fee paid: sum of input amounts minus sum of output amounts.


---

### Answer by username_3 on 2022-10-05. Score: 0

The Blockchain is public. You can query and analyze all or part of it by running your own node. That would eliminate the unanswered questions about how the explorer APIs you're using define their calculation bases

More importantly, fees are Bitcoin amounts, not dollar amounts. Expressing fees in dollar amounts is complicated by the volatility of the dollar per Bitcoin exchange rate. That is, for a 3-month average, an accurate dollar estimate can only be calculated by knowing the point-in-time exchange rate for every single block in the period

As far as I know, there are no free public sources of block-by-block dollar per Bitcoin exchange rates

The Bitcoin transaction fee is not explicitly recorded. As the @username_2 response says, the Bitcoin transaction fee is the sum of the output amounts subtracted from the sum of the input amounts. Note that the input amounts are not stored in the spending transaction. They are discovered by retrieving the amount from the transaction output being spent by each transaction input


---

