Ethereum Gas Fees are basically transaction fees that user have to play to miners on a blockchain protocol to have their transaction included in the block. Gas is a unit that measures the amount of computational effort it is required to execute a certain operation. As each transaction in the Ethereum network requires a fee, Gas represent the fee that is required to successfully conduct that transaction.
Gas is denoted as Gwei which is the smaller denomination of Ethereum (ETH). So 1 Gwei is equal to 0.000000001 ETH (10 to the power 9 ETH). Since, its gets really complicated if user paid transaction fees in the denominations of ETH as paying 0.000000001 ETH as fees seems crazy. This is the reason why paying in Gwei or Gas fees is more convenient. However, convenience is not just the reason for the existence of Gas fees.
Why are gas fees so expensive?
Gas fees are expensive because Ethereum is the second largest most used blockchain network on the planet. Due to that, there are too many people using the blockchain platform and too many transactions happening. Because of this, gas fees usually spike up in order for people to speed up their transactions.
Many people complain that there shouldn’t be any gas fees as Bitcoin doesn’t require gas fees at all. However, people forget that Bitcoin and Ethereum work in a totally different way. For Bitcoin, a person can send 5 BTC to his friend but there’s no way to add additional conditions to the transactions. Meaning it’s completely monetary.
But for the Ethereum blockchain network, they through something called Smart Contracts. Smart contracts help users exchange money, shares, property, or anything of valuable in a transparent, conflict-free way while still avoiding the services of a middleman.
They work in a step-by-step transaction basis and every transaction a user does is recorded on the network. This makes everyone involved with the contract responsible for their actions. This makes the Ethereum Network very secure as people cannot do fraudulent or cheating or spamming activities using the network as every action is visible on the network.
As Gas sets a limit on how many computational steps of code execution, the transaction can use. This is the reason why Gas prices tend to spike up if there are too many transactions and blocks being used and overloaded. For this reason, users might need more gas speed up the process, else they have to wait.
Why does Ethereum use Gas?
Now we know that Ethereum works on a Smart Contract basis which makes the Ethereum Blockchain network secure from spammers and fraud. However, another reason why Gas exists in the first place is because Ethereum is heavily dependent upon the hash-rates of it’s miners.
More miners means faster transaction times, more hash-rates and more security.
But in order to attract more miners, Ethereum has to makes it’s system profitable. Miners are able to make profits from the Ethereum network by mining blocks and getting rewards, and By becoming temporary dictators of their mined blocks.
However, in order to put the transaction inside the blocks, they will need computational power to validate smart contracts. The gas system from the Ethereum blockchain allows them to charge a fee, which is the Gas fee or also known as Miners Fee.
What is the Ethereum Gas Limit?
In order for the miner to complete the operation, the user or sender of the transaction must set a gas limit. The Gas limit is basically the max amount of Gas, the user will willy to pay to complete the transaction.
A simple ETH transaction has a Gas limit of 21,000 gas. Miners can only include transactions that add up to becoming less than or equal to the gas limit specified.
Gas limit is a very important topic in the Ethereum Blockchain as Gas is required to complete the ETH transactions. Also, different kinds of operations will have different set of Gas Limits and if the Gas is not enough, or if the user fails to set the required amount of Gas limit, the miner will stop executing the process of transaction. Moreover, the transaction will revert back to its original state as if nothing had happened.
Again, any unused Gas is refunded back to the user. Here, if you are thinking, users are normally required to set a Gas Limit above the required Gas amount needed for the transaction. So, if 21,000 Gas is required for the transaction, users are requried to set at least 21,100 Gas as the Gas limit for the transaction. However, many people may think that, if this is the case, why not just make the Gas limit very high, so one doesn’t have to worry about the transaction failing.
This may seem sensible but Miners too are also limited by block gas limit. If you set your gas limit to be too high, the miners may end up using too much of their gas block limit which in turn may make sense to you, but for miners, it won’t be good.
This is the reason why, the best option is to set the gas limit a little higher than the required amount needed for the transaction. This safeguard both the miners and the users and ensures that the transactions are successfully processed.
How do Ethereum Gas refunds work?
Normally, any unused gas is returned back to the user as refunds.
There are two ways by which users get back their Gas.
- SUICIDE: This is basically when your Smart Contract is completely killed. The user gets back 24,000 gas.
- SSTORE: This is called Storage deletion where the user gets back 15,000 gas.
To explain the second scenario, lets say a smart contract is using 14,000 Gas and Storage deletion takes place, so the user gets back, 15,000 -14,000 gas which is 1000 Gas getting refunded back to you. However, this isn’t the case at all and if this was true, miners would lose all their hardwork and profits as why would miner pay for your own computations right.
This is the reason why, conditions like SSTORE was put up that the refund that has been accumulated cannot exceed half the gas used up during computation.
For example: Lets say, the gas limit is set to 20,000 gas. How much do you think, the creator will get back? using SSTORE and 14,000 is the required amount.
First, they get back the unused amount which is 20,000- 14,000 which is 6000 gas. In theory, 15,000 gas should be refunded but that is not the case.
Because the amount of gas used in the contract is 14,000 and 15,000 is greater than 14,000/2 so the refund generated will be 7000.
So, the total gas, the user is getting will be 13,000 gas.
For the SUICIDE Refund method, its pretty straightforward, the user will get back 24,000 gas, plus the amount of unused gas.
Although, Gas fees can be really complicated, it is an integral part of the Ethereum Blockchain Network and it is because of the Gas System. Although, there are still pitfalls in the system, particularity due the to network congestion from DeFi due to which the transaction fees have become expensive. However, security is one thing that the Gas system provides us with.
By now, I hope you have a clear idea of what Gas fees really are and why are they included in the Ethereum Blockchain. Thanks for reading this article, and please be sure to share this valuable information with your friends, co-workers and family.