Understanding Ethereum's Gas and Transaction Fees
Share this article
Despite being dubbed the “lifeline of the Ethereum network,” gas is an obscure term outside of the Ethereum community. While it is often used to describe transaction fees on the network, really understanding gas requires diving a bit deeper into the mechanics of Ethereum.
Gas and Smart Contracts
ConsenSys defines gas as a “metering unit for use of the World Computer,” but it boils down to an even simpler explanation—the fee for using this world computer.
That said, it’s worth noting a few significant differences. Gas represents much more than just the cost of processing transactions on the Ethereum network. Ethereum is capable of running all sorts of apps, allowing it to form the basis of the decentralized web. As such, while gas could technically be described as “transaction fees,” it should be used with caution.
The Ethereum Yellow Paper, written by one of the network’s creators, Gavin Wood, lists precisely how much a specific instruction on the network costs in gas:
Every type of instruction performed on the network has its own fixed price. To figure out the cost of a transaction or smart contract, simply add up the value of every instruction it performs.
The problems, however, arise when the gas fee actually has to get paid.
The term that best describes gas is fuel for the Ethereum network. But fuel isn’t a currency on its own, it needs to be bought and denominated in dollars or euros.
The same goes for gas. For it to be paid, it needs to have its value expressed in Ether, the underlying cryptocurrency of the Ethereum network. Like oil, there is no fixed price to convert gas to Ether. It’s left to buyers and sellers (miners) to come up with a price suitable to both sides. This pricing is achieved through a virtual auction.
How Gas Works on the Ethereum Network
For an instruction to execute on the Ethereum network, the sender of the transaction needs to specify a “gas limit” before submitting it to the network. The gas limit is the maximum amount someone is willing to pay for their instructions to go through and get processed.
The processors of these transactions, server operators, known as miners, have a few choices when they receive a pending transaction. First, they can accept the transaction by processing the instructions with their computers, using electricity in the process, and keep the attached fee set by the sender. They can also refund some of the gas to the sender if the sender set a higher gas limit than was necessary for the transaction. Alternatively, they can decline the transaction if the sender set a lower gas limit than what the market was paying at the time.
If a transaction’s instructions, mid-execution, run out of gas as a miner is processing it then it is “reverted back to its original state.” In other words, the transaction is returned to the sender. Nevertheless, the sender must still pay a fee to miners to compensate them for the computing power they spent processing the transaction, even if it was only partially completed. Miners must also add the transaction to the blockchain, even if it wasn’t fully executed. If the sender specifies a higher gas limit than was necessary, then the miner would refund the difference to the sender.
While this mechanism has been widely praised for the way it handles transactions, it is prone to complications in reality.
The problem is especially acute for transactions with high gas limits. For Bitcoin and other payment-focused blockchains, paying more usually means that transactions get sent faster. This isn’t always the case with Ethereum. For each block on the Ethereum network, miners are bound by the maximum “block gas limit,” which determines the maximum amount of gas that can be spent per block.
With the current block gas limit set at roughly 10,000,000 gas, miners are less inclined to include transactions with high gas limits because it would waste part of the block gas limit. For these high gas transactions, much of it will usually get refunded by the miner. Instead, miners opt to take smaller transactions.
For example, it makes more economic sense for miners to include two separate transactions with gas limits set at 21,000 gas than one transaction with a gas limit of 42,000 gas.
The Problem with Fees
For Ethereum to work as a world computer, fees on the network need to be minuscule. As such, the way to pay for these transactions, Ether, also needs to be denominated in minuscule amounts.
To keep track of fees, Ether is denominated in several smaller increments, the most widely used one being the gwei. Also called nanoether, gwei denotes the ninth power of a fractional Ether—1 gwei equals 0.000000001 ether (10^-9).
There are other denominations of Ether as well, all named after influential figures in the world of cryptography. None of them, however, are as widely used or as recognized as gwei.
How to Calculate Ethereum Transaction Fees
There are several ways to calculate the fee necessary to execute a transaction on the Ethereum network. The network is set up in such a way that any arbitrary fee can be set. So, in theory, a sender could select any number as the transaction fee they’re willing to pay, no matter how minuscule (well, as low as one gwei).
It doesn’t work that way in reality since miners are still motivated by fees.
There are dozens of gas calculators available online that allow aspiring Ethereum users to get a general idea of how much gas their transaction will need. We recommend ETH Gas Station for its intuitive interface and accuracy.
At press time, it would cost 23 gwei, or around $0.091, to send a transaction in under 5 minutes. To send a transaction in under 2 minutes, it would cost 34 gwei, or about $0.135.
That said, these recommended prices are only estimates. Whatever the gas price, there is still an element of uncertainty. A 21,000 gas transaction with its gas price set at 35 gwei was accepted by 97% of the last 200 blocks (30 minutes or so). The average time for a transaction with these characteristics to get confirmed on the network was 21 seconds, according to the calculator.
Even so, it’s possible to determine transaction fees on the Ethereum network without an online calculator. A prospective sender just needs to know how much gas each operation on Ethereum requires, and then have a basic understanding of the average market rate for gas prices.
For example, a simple token transfer on the Ethereum network requires 21,000 gas to complete. The third week of April saw an average gas price of around 20 gwei. Therefore, calculating the transaction fee requires multiplying the required gas units with the going gas price.
21,000 gas x 6 gwei = 126,000 gwei = 0.000126 ETH
At current prices, a user sending a 21,000 token transfer will pay a gas fee of $0.021 for the network to process and validate it.
Problems With Ethereum’s Auction Mechanism
Ethereum uses the “first price auction” system to price gas. The system works by having every sender submit a bid, known as a gas limit, for how much they’re willing to pay. Miners then pick up desirable transactions and include them in the next block. In theory, this allows senders to prioritize their transactions by paying a higher fee while saving ETH through refunds. In reality, this mechanism has serious flaws.
What usually happens is that miners select transactions with the highest bids, causing senders to set even higher bids on other transactions they make. There is also a problem of transparency. There is no way for someone to know what bids came with other pending transactions, which also results in overpaying.
Eric Conner, the founder of Ethhub, an open-source education hub for Ethereum, noted that there is often a considerable divergence of transaction fees paid by different senders in a single block. Conner suggests that many users often overpay by more than five times what was necessary, according to his data.
Ethereum Improvement Proposal (EIP) number 1559 addresses this problem by proposing a base fee on the network. The EIP, called BASEFEE, would then adjust this figure depending on how congested the network is.
The currently used auction mechanism doesn’t take into consideration the demand for the network, which has led to severe congestion. In some cases, this has even caused the Ethereum network to grind to a standstill for some applications.
To make a system such as BASEFEE work, the maximum gas capacity of a block would need to double from 10 million to 20 million. That way, the block gas limit could adjust dynamically. For example, if the network were at 50% utilization, an average load, the new system would set the block gas limit to 10 million.
Conner suggests that when more than 50% of the network is utilized, the base fee increases, and vice versa. This, he explained, will allow wallets to automatically set the gas fees for users in a reliable fashion, effectively removing the need for manual fee adjustments.
The most notable aspect of this proposal is that miners would no longer be able to profit from fees. BASEFEE proposes that fees are destroyed rather than given to miners, forcing miners to earn revenue through block rewards alone (about $3.5 million per day split between all miners). Destroying fees would prevent miners from manipulating transactions to get more money from senders. It would also ensure that only Ether could be used to pay for transactions, cementing its value.
Miners would instead profit from “tips,” small fixed amounts of money set by wallets to compensate them. A higher tip will ensure faster settling times, but it won’t lead to involuntary over-payment, as is often the case with the current system.
Many expect this update will find its place in Ethereum’s upcoming iteration, Ethereum 2.0, which will bring about staking and drastically increase Ether’s economic value within the network.