The article data is available on GitHub.
Transaction fees in Ethereum have always been a hot topic. The cost of running applications, can determine the choice between smart contract platforms. And with many other blockchains eager to catchup with Ethereum, a spike in transaction fees is bound to hit the news.
In the last few months, Ether has been steadily appreciating. The rally gained significant momentum leading to a jump of $200 in less than 1 month. In mid-July Ether was at around $230, whereas in mid-August the price went over $430. This rally was coupled by a steep rise in transaction fees, fueling old concerns that transaction fees could hamper further adoption of the Ethereum blockchain.
As I was following the debate, many transaction fee figures started surfacing. The most conservative quoted fees of $2/$3, whereas the most outrageous were at $40. These could not be possibly all true!
Luckily, in the world of public blockchains, we do not have to trust anyone. The data is there, we just need to take the trouble of collecting and analyzing it. This is exactly what I did and here are my findings.
Gas Used, Gas Price and Gas Limit
In Ethereum, transaction fees are charged using the Gas unit. If you already know what Gas is, jump to the next section. Otherwise here is a quick explainer.
As an example let's look at transaction id 0x19481e2b19a37b53c8e5f46b8db252984b5ddbd5a8439caddcf3c10a5ec1eb1a on Etherscan.io:
The red box highlights the transaction fee information. Of these 5 values, only the Gas Limit, Gas Used and Gas Price are available from the blockchain. Transaction Fee and Ether Price are provided by Etherscan for convenience.
Transaction Fee shows the fee paid in Ether, and its USD equivalent. This is computed by combining the Ether Price, Gas Used and Gas Price values.
Ether Price shows the price of 1 ETH in USD on the date this transaction was processed (15th July 2020).
Gas Used is the amount of Gas consumed by this transaction.
Gas Price is the value of a single Gas unit. Very often this is quoted in Gwei, where:
1 Gwei = 0.000000001 Ether
Gas Limit is the maximum amount of Gas a transaction is willing to pay.
The following table shows how Gas, Ether and USD relate to each other:
Transaction Fee Unit |
Equation |
Computation |
Result |
Gas |
Gas Used |
21000 |
21000 |
ETH |
Gas Used x Gas Price |
21000 x 0.000000018 |
0.000378 ETH |
USD |
Gas Used x Gas Price x Ether Price |
21000 x 0.000000018 x $ 238.42 |
$0.09 |
One important point to appreciate here is that the Gas Price is not fixed. Each transaction is quoting its own Gas Price.
Imagine a client proposing the price to a service provider. If the provider agrees, the requested service is rendered. In this analogy, the client is the one submitting a transaction, for example someone wanting to transfer Ether. The service provider is the miner, the one cashing the fee if the transfer is fulfilled.
This mechanism allows users to compete against each other for their transaction to be processed by miners. The higher the quoted Gas Price, the faster a transaction is processed. What this means to us, is that each transaction is quoting its own Gas Price.
Extracting Gas Price Information
With a clear understanding of Gas, we are ready to extract the data from Ethereum.
I wanted to have all the data covering the latest price rally, from the point when Ether was at $230, up to the point when it reached $430. This is covered nicely with 1-month worth of blocks, between:
Block 10460735 with timestamp Jul-15-2020 12:00:04 AM +UTC
Block 10661251 with timestamp Aug-15-2020 12:00:36 AM +UTC
That means 200,517 blocks which together include 36,334,356 transactions.
Gas Price Mean and Median
There is a lot of data in 36,334,356 transactions. To speed up the process, instead of logging each transaction, I grouped the Gas Price by block.
For each block, I recorded the arithmetic mean and median of the Gas Price. Our goal is to identify a Gas Price that allows us to perform an Ether transfer at a given point in time, without incurring an excessive fee and without risking being left out of the blockchain for too long.
Furthermore, in general the median is more representative of the going Gas Price than the mean. The latter is often skewed by a few transactions that have a good reason to quote an above average Gas Price to ensure immediate processing.
The resulting data log looks like this:
Block, Total_Trns, Mean_GasPrice, Median_GasPrice
10460735, 87, 26962730789, 23000000000
10460736, 109, 28112018393, 23100000000
10460737, 51, 23340686274, 20100000000
10460738, 43, 26201605235, 23000000000
10460739, 155, 23921804155, 23000000000
10460740, 242, 31230197324, 26400000017
10460741, 173, 33996167026, 30000000000
In this manner, the data for all blocks was condensed to just under 7MB. Get the data from github.
Where is the value for Gas Used?
The log does not include the Gas Used. This value depends on the transaction type. A simple Ether transfer consumes 21,000 Gas. Transactions executing smart contract functions, may easily consume a lot more.
To analyze transaction fee variation over time, we must consider a single transaction type i.e. the Gas Used must be fixed. For this purpose, we use 21,000 Gas as our benchmark.
Our Gas Price data still includes all transactions since all are competing for blockchain inclusion. If one transaction type offers a higher than average Gas Price, such offer influences the going price for all other transactions.
USD Rate
When quoting fees in USD, I am using a fixed rate of $430/ETH. This is the highest rate for the data sample. More accurate results could have been obtained by pulling hourly USD quotations from a crypto exchange.
With my approach, USD values will obviously be skewed upwards. However, this is fine since my goal is to explore the upper limit. At worst I will quote higher fees.
One important advantage of fixing the USD rate is that the resulting graph will have a single variable, the Gas Price. We can see this by referring back to the USD Transaction fee equation:
USD Transaction Fee = Gas Used x Gas Price x Ether Price
USD Transaction Fee = 21000 x 430 x Gas Price
Thus, the resulting graphs will directly reflect the variation in Gas Price over time.
In any case, the raw data is not littered with any USD rates. Anyone wanting to factor in a variable USD rate is welcome to do so.
Test Data Summary
First block |
10460735 |
Last block |
10661251 |
First block timestamp |
Jul-15-2020 12:00:04 AM +UTC |
Last block timestamp |
Aug-15-2020 12:00:36 AM +UTC |
Total blocks |
200,517 |
Total transactions |
36,334,356 |
Gas Used Benchmark |
21,000 Gas |
USD rate |
$430/ETH |
Results
Highest Gas Price Mean |
4514.54 Gwei @ Block 10658796 |
Highest Gas Price Median |
1500Gwei @ Block 10658796 |
Highest Transfer Fee Mean |
$40.77 @ Block 10658796 |
Highest Transfer Fee Median |
$13.55 @ Block 10658796 |
Lowest Gas Price Mean |
0 Gwei @ Block 10479779 |
Lowest Gas Price Median |
0 Gwei @ Blocks 10462385, 10462729, 10464002... |
From this summary we can immediately see that block 10658796 did indeed record a whopping transaction fee mean and median of $40.77 and $13.55, respectively. The difference between the two indicates that the mean is skewed. Nevertheless a $13.55 median is still extraordinarily higher than what we had a few weeks earlier.
However, are these values truly representative of the transaction fee levels around that time? Let us look at the results for the 5 blocks preceding and following this block.
Block Number |
Mean ($) |
Median ($) |
10658791 |
1.20 |
1.70 |
10658792 |
2.02 |
1.99 |
10658793 |
2.27 |
1.81 |
10658794 |
5.82 |
1.90 |
10658795 |
2.74 |
1.81 |
10658796 |
40.77 |
13.55 |
10658797 |
5.89 |
2.80 |
10658798 |
2.13 |
2.26 |
10658799 |
11.37 |
2.71 |
10658800 |
4.66 |
2.17 |
10658801 |
10.48 |
2.80 |
From this table it looks like block 10658796 was a one-off! Furthermore, we can see how the mean keeps spiking. This is why the median is more trustworthy. Except for block 10658796, the median data is concentrated between $1.7 and $2.8.
Oh, and did you notice the lowest Gas Price mean/medians? We have some zero fee transactions! Now that is an interesting topic worthy of an article of its own.
Visualizing the Data
Fee Lower Range Histogram
The first histogram shows how for most of the time the transaction fees are below $2.20. However, we do have over 7000 blocks where the fee is above this level. So, let us expand the range.
Transfer Fee Histogram
From here we can see that very few blocks go above $4.25.
Next, we plot the fees against the block numbers. Keep in mind that in Ethereum we have a new block approximately every 13 seconds. Thus, we are effectively plotting fees against time.
Transfer Fee vs Time
This graph initially shows little variation in the median. But at the end we see the fees taking-off. Let us zoom into the last portion of the graph.
Transfer Fees for Blocks 10636817 to 10661251
Ignoring the spikes, we again see the fees peaking at around $4.
Concluding Remarks
There is no doubt that a jump in transaction fees is a matter of concern. Some claims were certainly exaggerated, but one should still be wary of downplaying the issue.
High fees will make running smart contracts more expensive. DeFi applications may be tempted to look for blockchains offering lower running costs. Beyond DeFi, a blockchain that aims to be the world computer, should aim to run a broader range of applications. The higher the fees, the harder it gets for this diversity in applications to grow.
On the positive side Ethereum 2.0 is making progress and we are promised that this issue is being addressed...