What Are Ethereum Gas Fees and How Do They Work?

What Are Ethereum Gas Fees and How Do They Work?

Ethereum Knowledge

Crypto APIs Team

Mar 14, 2022 • 8 min

If you want to use the Ethereum blockchain, then you’re going to come in contact with “gas”. Ethereum gas refers to the fees incurred by all users for executing any transaction or function on the Ethereum blockchain.  

But what is this gas for exactly and how does it work? 


What is Ethereum Gas? 

Ethereum gas is the fee for transactions made on the Ethereum blockchain and every transaction you make requires gas. Think of it in the same way as a car needs gas to move.  

If you want to move Ether (ETH), Ethereum’s native cryptocurrency, between addresses, then you’re going to need to pay for gas. Or if you want to mint your own NFT or exchange ETH for other tokens, that too is going to cost you gas.   

Gas fees can only be paid for in ETH and prices are denoted in gwei, which stands for giga-wei (wei being the smallest denomination of ETH). 

A gwei is equal to 1,000,000,000 wei or 0.000000001 ETH. 

What Are Gas Fees For? 

Transactions on the blockchain don’t just happen automatically. There is a considerable amount of computational power that goes into the processing of each and every transaction. That process is done by miners and the gas fees are basically the reward given to them for validating transactions and adding them to the blockchain.   

The gas fees are therefore an incentive for people to become miners and participate in maintaining the integrity of the decentralized ledger.  

They are also a way to secure the Ethereum network. Requiring a fee for every transaction helps prevent spamming of the network by bad actors and avoids accidental or hostile infinite loops.   

How Do Ethereum Gas Fees Work? 

The gas fees are made up of two things, the gas limit and the gas price.  

But what’s the difference?  

Gas limit 

The gas limit is the maximum amount of gas that you’re willing to pay to run a transaction.  

A standard ETH transfer has a gas limit of 21,000 units of gas but more complex transactions require more gas because they require more computational power.   

For instance, executing a smart contract requires more computational power than a standard transaction, therefore the gas limit will have to be higher.  

If you set the gas limit lower than what is required, the transaction will fail. But since it’s still been mined, you’ll lose the gas used up to that point. 

When the gas limit is higher than what the transaction need is, only the required amount of gas will be deducted and blockchain refunds the unused gas. 

Keep in mind that, if all other variables are the same, a transaction with an unnecessarily high gas limit could be less appealing to miners. Therefore, it doesn’t make sense to put a high limit even when only the needed amount of gas is deducted. 

Gas price 

The gas price is the amount you want to pay per unit of gas. The gas price fluctuates depending on how busy the Ethereum Virtual Machine is. The busier the network, the more you’ll need to pay. 

Setting a higher gas price (how much you’re willing to pay per unit), means your transaction will be more attractive to miners and likely to be processed sooner. Set it too low and you could be in for a long wait or left with an unmined transaction. 

To better understand how gas fees work let’s go back to our car and gas analogy.  

Computational power is like gas consumption for your car.  

It’s the amount of petrol that you need to get from point A to point B in a car.  

The further you need to go (the more complex the transaction), the more gas you will need.  

If you need 21,000 liters of petrol to get to point B, but you only have 20,000 you won’t complete your journey.  

If you have 22,000 liters of petrol, only 21,000 will be consumed. 

The gas limit is the amount of petrol you will put in the tank.  

The gas price is the price you pay for each liter of petrol. When there is high demand for petrol, the cost per liter increases.  

In the case of Ethereum, the more you’re willing to pay per liter, the faster your “car” (transaction) will reach its destination (the blockchain). 

How Are Gas Fees Determined? 

Currently, there are two fee models in use due to a recent hard fork in the Ethereum blockchain, called the London Upgrade. The upgrade was implemented in August 2021 in part to address the skyrocketing fees but also to reduce the environmental impact of Ethereum’s unsustainable energy consumption.  

Pre-London Upgrade 

The initial fee model, which will be phased out over the next year, uses a first-price auction mechanism.   

To have your transaction picked up by a miner, users have to bid for it to be added to the block by submitting the gas price you're willing to pay for the transaction. The miners pick up a transaction sorting them by the highest gas price and processing the most profitable ones first.   

As the Ethereum blockchain has grown busier, with more dApps using smart contracts and the rising popularity of NFTs, the gas fees soared. Users could end up paying the equivalent of $100 in gas fees just to deposit $50 worth of cryptocurrency. 

To combat the rising fees and network congestion, the London Upgrade was introduced. This consisted of five EIPs (Ethereum Improvement Proposals). The most interesting of these in terms of fees is EIP-1559. 

Post-London Upgrade 

EIP-1559 introduced the concept of the base fee which represents the minimum fee that has to be paid for a transaction to be included in a block.   

This base fee is set per block and can be increased or decreased, depending on how busy the network is.         

When the network is at more than 50% capacity, the base fee is increased, and when it’s lower than 50% utilization, the base fee is decreased. The amount that the base fee can be increased/decreased is constrained to 12.5% per block.  

This upgrade also increased the network capacity by doubling the gas limit per block from 12.5 million to 25 million gas.  

Both of these changes help reduce congestion and mean that fees are easier to predict as they correspond to the information from the previous blocks. 

One other important aspect EIP-1559 introduces is a miner tip which is completely separate from the base fee.  

To avoid the risk of miner collusion to artificially inflate the base fee for the miner’s benefit, only the miner tip goes to the miner and the entire base fee is burned (destroyed). Hence the name of the fork...the fire of London. 

How Crypto APIs Calculates the Gas Fees 

Now that you know how Ethereum gas fees work, you can forget all about it. 

Why?  

Because Crypto APIs’ endpoints relieve you of the burden of trying to estimate gas fees for your transactions, paying too much, or waiting for transactions to be processed. 

Estimate Gas Limit 

This endpoint gives information for gas expenses when sending ether to contracts or making a transaction with additional data in it. 

Use it to get details such as: 

  • transactions amount; 
  • recipient’s address receiving the transaction;  
  • and the address sending the transaction. 

Estimate Token Gas Limit 

Access information for gas expenses for a specific contract when sending ether or making a transaction with additional data in it. This endpoint returns details for Ethereum, Ethereum Classic, and Binance Smart Chain. 

The details returned include: 

  • transactions' amount; 
  • the specific token identifier. For Ethereum-based transactions, it is the contract; 
  • the ERC contract type (ERC20 or ERC721); 
  • and the addresses receiving and sending the transaction. 

Get Fee Recommendations 

Our fees recommendations are based on Mempool data which makes them much more accurate than fees based on already mined blocks. Calculations are done in real-time and live.  

You can receive fee recommendations per byte calculated from unconfirmed transactions for the different priority levels, fast, slow, and standard. 

Using this endpoint customers can get the gas price for more than just Ethereum and Ethereum Classic. It also returns details for other blockchains such as Bitcoin, Bitcoin-Cash, Dogecoin and more. 

Get EIP 1559 Fee Recommendations 

Through this endpoint, customers can obtain fee recommendations specifically for the London Upgrade EIP 1559 fee model, including: 

  • the unit of the base fee per gas and the maximum priority fee per gas in wei 
  • the expected base fee per gas of the upcoming block, calculated from the previous block data. 
  • the maximum fee per gas, calculated from unconfirmed transactions for fast, slow and standard 
  • the fast maximum priority fee per gas, calculated from unconfirmed transactions for fast, slow, and standard 

Crypto APIs helps you make the best decision on how much you would like to spend on fees at a certain time and optimize your business operations. To learn more about our unified endpoints check out our documentation or contact us to talk to a technical representative. 

Related articles

Share