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!

3 Answers 3


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


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.


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 @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.