Ethereum Gas Explained: A Guide to Gas Fees
By Maddie Stein
There are several essential components to any interaction that happens on the Ethereum blockchain - one of those components is gas.
You have to pay gas on every transaction, whether it’s buying an NFT or swapping tokens, in order to pay for the resources required to make that transaction happen on the Ethereum blockchain. Similar to how its physical namesake is needed to make a car go, gas is what makes the blockchain operate smoothly.
So What Exactly Is Gas?
Since Ethereum is currently a proof-of-work network (with a planned transition to proof-of-stake later this year - more on that later), every transaction needs to be processed and validated by miners.
Miners need an incentive to perform that work - which is where gas comes in.
Gas is a unit that describes the amount of computational work miners need to do. The gas fee is the price users need to pay to cover some of the costs associated with the computational work and resources needed to run the network.
Gas fees are paid in ether, the Ethereum native currency. However, gas prices are usually expressed in gwei - a denomination of ether. Think of it like this: gwei is to ether what pennies are to a dollar. Instead of saying your gas fee cost 0.000000001 ETH, you can just say it cost 1 gwei.
Gas fees are not only an incentive for miners, they also serve to prevent users from spamming the network with malicious or unnecessary transactions. When every transaction has a cost, it’s not so easy to send thousands of spammy transactions per second!
How Are Gas Prices Determined?
Unlike something like an ATM fee, which is a fixed charge regardless of how much money you’re taking out, the gas fee can vary widely, which is a headache for users. This was especially true before the London upgrade, which was implemented in August 2021.
Currently, the gas price is calculated through the following formula:
gas fee = gas units (limit) * (base fee + tip)
Let’s break it down!
Gas limit
Gas limit represents the total amount of gas you want to spend per transaction. It’s expressed by units - for example, for basic Ethereum transactions, the minimum gas limit is at least 21,000 units. Anything less than that means your transaction won’t get picked up and processed by miners.
As transactions get more complex, the 21,000 limit required to execute the transaction increases. While most wallets give you a choice of a low, medium or high gas limit, you can also manually set your limit (for instance, making it even higher if you’ve got a transaction you want to be certain gets completed quickly).
Base fee
The London upgrade introduced the base fee, which is expressed in gwei. Each block has a minimum base fee that needs to be met for a transaction to be included. The good news with the London upgrade is that the fee is calculated based on previous blocks, making gas prices more predictable.
The base fee changes based on the current network demand, going up when more users are all trying to get transactions written to the blockchain at the same time.
Tip
Also known as the priority fee, this is another London upgrade innovation. Prior to this upgrade, the base fee was determined through users bidding to get included in the block. These fees were paid out to miners. With the London upgrade, the base fee is determined by the network, and once paid, the ether is burned, i.e. taken out of circulation.
To continue providing incentives for the miners, the London upgrade now allows users to set the tip, i.e. the priority fee. This amount is paid out to miners. You can set the tip as high or low as you want, and some wallets will provide a suggestion. Generally, if there’s a transaction you need to execute quickly, a higher tip is a good bet that the miners will pick it up sooner.
But wait… What is the “max fee” I see in my wallet?
In Metamask in particular, the max fee equals the base fee plus tip. You can adjust the max fee and pay more to execute the transaction. Luckily, the amount you overpaid will be refunded, as another benefit of the London upgrade. Once the transaction is executed with the base fee, you’ll get a refund based on this formula: refund = max fee - (base fee + priority fee).
So, to come back to the main formula:
At least 21,000 units * (gas fee based on network congestion at the time + tip for the miners) = total gas fee
OR
21,000 units * (100 gwei + 10 gwei) = 2,310,000 gwei or 0.00231 ETH
Why are gas fees so high sometimes?
Gas fees are dynamic, changing minute to minute and even second to second. They are mainly a function of transaction complexity and network demand. More information being written to the blockchain results in higher transaction complexity and higher gas fees.
For example, sending cryptocurrency is more straightforward than minting an NFT. The former is a relatively simple change (person X now has 10 more ETH and person Y has 10 less), while the latter is more complicated (including information like the owner’s address, token ID, and NFT metadata).
As we explained just above, users have the ability to set their own fees. This means that if a lot of users really want to execute transactions, they can set high limits and tips, driving up the costs across the network. You’ll see big spikes in gas fees in instances like the minting of a popular NFT project.
So as more and more users are onboarded to crypto, and interest in NFTs and DeFi continues to grow, we may have to get used to a new normal of higher gas fees. However, this isn’t news to Ethereum developers - which is why there are plans set in motion to upgrade to Ethereum 2.0. This upgrade should increase the throughput of the network (in other words, the number of transactions per second that the network can handle). Given gas fees are a function of demand, the ability to better meet this demand by efficiently handling more transactions faster should reduce gas fees.
Can I Avoid High Gas Fees? How?
You can - to a certain extent. Since you’re ultimately in charge of the limit and the tip (the priority fee) you set, you can always set these to a level you’re comfortable with. But be careful - if you set your limit too low, the transaction may consume all your gas but fail to execute. So you’ll still be stuck paying the gas fee.
Certain times of day seem to have higher fees (for instance, when waking hours overlap between Europe and the US). So if you’re a night owl by nature, you may be in luck. You can also check the current gas prices and wait until they’ve gone down to execute your transaction. BlockNative’s Gas Estimator is a really useful tool for estimating the amount you’ll need to pay for your transaction to be included in the next block.
And if you’re completely fed up with high gas fees on Ethereum, you may want to look into Layer 2s. These are essentially protocols built on top of Ethereum that handle transactions off the “Layer 1” main chain. One example of this is Polygon, which can handle a much higher throughput than Ethereum, better meeting user demand and leading to lower gas fees.
And when it comes to NFTs and minting?
While you can’t control the demand for a particular NFT project you want to mint, you can take some steps to ensure your gas fees remain reasonable.
Many NFT projects (Surge included) have started implementing more efficient and concise smart contracts. In this way, the project sets rules that help minimize gas fees for minters.
You can also try to get on presale lists for NFT projects you’re interested in, as these lists usually mean fewer people are minting at a particular time. When you get on a presale list, your minting spot is secured and you usually get a window of approximately 24hrs to mint your NFT when gas is the lowest.
You might also want to look at the calendar and check that no other major projects are minting at the same time - this is something developers should also be mindful of when setting mint dates.
Ultimately, reducing gas fees comes down to timing, a bit of luck, and hopefully the upcoming Ethereum upgrades.
Have any questions? Hit us up in Discord or on Twitter and make sure to sign up to our newsletter!