The Ethereum network, unlike Bitcoin and many other cryptocurrencies, operates not only the main cryptocurrency, but also Gas. It is Gas that allows users not only to make transactions, but also to run smart contracts, deploy DApps, and store information on the blockchain. In this article, we will take an in-depth look at what Gas is in Ethereum, talk about what it is used for, and how to optimize its costs.
What is Gas in Ethereum
We are all used to having to pay a fee to miners for their services to verify transactions and support the network in order to make transactions on the blockchain. And the Ethereum network is no exception. However, in Bitcoin and many other cryptocurrency networks, the commission process is quite simple. The user only needs to choose the optimal amount of commission and wait for the transaction to occur. Pay more – the transaction will go faster, less – you’ll have to wait a bit.
With Ethereum, it’s more complicated. The commission for transactions in the Ethereum network is calculated in gas and paid in ETH. That is, the more energy-consuming the transaction, the more gas it will take, and the higher the commission will be.
Essentially, Gas is the unit of calculation on the Ethereum network that is used to calculate fees for a transaction or action on the blockchain. Ethereum Gas is also often referred to as the fuel of the network. Using the analogy of regular fuel, the easiest way to explain what gas is in Ethereum is.
Imagine that you are going to go somewhere by car and you need a certain amount of gasoline to do so. You go to a gas station, fill up your tank with the right amount of fuel, and pay for it. If you draw a parallel to this situation with Ethereum, the trip you’re about to take is a transaction, the gasoline is Gas, and the gas stations are miners.
Why does Ethereum need Gas?
The Ethereum network combines more functions than the usual cryptocurrency. ETH can be used to send cryptocurrency transfers between users, but the main purpose of Ethereum is to create and execute support for smart contracts. The concept of using gas allows Ethereum to share the computational cost of EVMs and the real value of ETH.
The second reason is to incentivize miners. Many dApps are deployed on Ethereum smartcontracts, which integrate a variety of fields: games, insurance, finance, real estate, and more. Naturally, such a network requires special protection, and in the case of blockchain networks, the security of the network is directly proportional to its hash rate, i.e. the number of miners.
In order to encourage miners and offer them attractive earning conditions, a gas system was introduced. With it, miners can receive a commission commensurate with their resource costs, because the more complex the transaction, the more gas it takes to complete it.
When does gas apply
Ethereum Gas appears in any transaction that requires payment of a fee. Specifically, gas is needed to:
- To make a transfer of ETH to another wallet;
- to create a smart contract on the Ethereum blockchain;
- execute a smart contract on the Ethereum blockchain.
Each of these operations requires a different amount of gas to perform. For example, a cryptocurrency transfer would require 21,000 gas. The cost of creating and executing a smart contract depends on its complexity and how many EVM commands will need to be executed.
How much does gas cost
There is no fixed price for the cost of gas. The sender sets two key parameters for each transaction:
- Gas Limit – the maximum gas limit that can be charged for a transaction.
- Gas Price – the price of gas selected by the initiator of the transaction.
- Gas Limit is primarily a function for developers. It allows you to warn users against huge expenses as a result of an error, a huge or infinite contract cycle. For example, if a transaction requires only 21k gas, and the user has set a limit of 50k, the unspent difference will be returned to his wallet. At the same time, if a lower limit than required was set, the gas will be wasted and the operation will be rejected.
With the Gas Price parameter, users of the cryptocurrency network can control the speed of their transactions. After all, the principle of price priority also applies in the Ethereum network: the transactions with the highest value are the first to be included in the block.
The cost of gas is measured in the minimum part of the Ethereum – wei. However, in most wallets this parameter is specified in Gwei. 1 Gwei equals 1 million wei. So, for example, if Gas Limit is set to 50,000 and the sender specified a price of 20 Gwei for one unit of gas, the transaction will cost him 0.001 ETH.
The average price of Ethereum gas is usually 50-60 Gwei. But this parameter can change depending on the load on the network. For example, the surge in interest in DeFi in 2020 caused the cost of gas to jump from 11.7 Gwei to 538 Gwei.
The cost of gas goes up for two main reasons:
- When a large number of transactions pile up, miners are more selective in checking transactions, favoring those with the highest rewards.
- Users start setting a higher cost of gas in order to get their transaction validated as quickly as possible.
- Thus, when the network is overloaded, transactions become slower, and the auction effect causes the cost of gas to rise as well.
How to properly calculate the cost of gas
To many who have only experienced transactions on the Bitcoin network or others with a simplified fee system, the concept of gas and its effect on transaction speeds can seem complicated. But take just a few minutes to study the issue and you can easily find the best gas price and optimize its costs.
The gas price is determined by the initiator of the transaction at his discretion. However, it is important to set an optimal price that corresponds to the current load on the network so that the transaction will not hang up and be completed on time.
Special services can be used to calculate the optimal gas price. For example, at ethgasstation.info, you can see the current recommended price of gas for different types of transactions.
In the calculator section, you can calculate the cost according to your desired rate. Just enter into the calculator the cost of gas that you are willing to pay, and the service will calculate the amount of time you can expect confirmation.
Note that some wallets automatically substitute the optimal cost of gas, and some allow you to adjust this parameter only in a limited range.
How to reduce the price of Gas
The cost of gas can be adjusted according to the desired speed of transaction processing. For example, if you refer to the aforementioned ETH Gas Station service, for an instant check, the service now suggests setting the cost of gas at 75 Gwei, for a transaction within two minutes 72 Gwei, and for a standard transaction in five minutes 64 Gwei.
But these are only recommended parameters, based on data from the last 10,000 blocks. Setting a lower Gwei value will allow the transaction initiator to save money. This is relevant if the timing of the transaction is not of huge importance and you can wait.
If you open the service calculator and calculate the transaction rate at a minimum gas cost of 0.1 Gwei, you will notice that it will be verified after about 3,000 blocks. And if you consider that the mining time per transaction block on the Ethereum network is only 15 seconds, then even with the minimum fee, the transaction will be done in less than 12 hours.
But there are also a number of cases when it is better not to underestimate the cost of gas. For example, when participating in an ICO, it is recommended to set exactly the value of gas that was specified by the organizers.
Is it possible not to pay at all?
Yes, you can only pay a conditional fee of 1 wei for an Ethereum transaction. The thing is that the size of a block in the Ethereum network is measured not in bytes, like in Bitcoin, for example, but in the maximum amount of Gas that is required to process it. And often you can see that the blocks are not filled. For example, if we look at a selection of recent blocks, we can see that some of them are less than a third full and are using 8-30% of the Gas limit.
This indicates that the transaction queue is small. Therefore, even if we set a minimum value of 1 wei for the cost of gas, the transaction will still pass. However, it is not possible to calculate an approximate time for its verification, as it will depend on other transactions in the network.
But sending a transaction with a minimum fee is not so easy. The thing is that many wallets allow you to change the cost of gas only in a certain range. For example, in the official wallet of Ethereum and MyEtherWallet, the size of the minimum value of gas is limited to 1 Gwei.
To get around this requirement in MyEtherWallet, visit the Send Offline tab. There you can set the fee in wei, not Gwei. Using online wallets through your Google Chrome browser, you can change the minimum commission value through the developer toolbar. To do this, hold down the key combination Ctrl + Shift + I, and then click on the value change slider. Then in the code of the page change the initial value from 1 to 0.000000001, which will be equal to 1 wei.
Important: Transactions with a gas cost of 0 wei will not be executed.
Frequently Asked Questions
Knowing what Gas in Ethereum is, it’s easier for crypto-network users to navigate through setting commissions and avoid transaction hang-ups. Below, we’ll provide answers to a few more common user questions to get a definitive understanding of the issue.
Does gas in ETH have a limit?
Currently, the gas limit per block on the Ethereum network is 30 million. This parameter determines the bandwidth of the network and what the maximum amount of gas can be consumed when forming a single block.
Initially, this parameter was set at 12.5 million and remained unchanged until the creator of Ethereum, Vitalik Buterin, proposed to raise it. Miners can also adjust the gas limit, but by no more than 0.0976% of the parameters of the previous block.
Increasing the gas limit will allow more data to be included in each block, which in turn reduces the turn of transactions and allows for lower commissions.
How does gas and commissions affect the miner?
The cost of gas directly affects the profitability of mining on the Ethereum network. Miners are rewarded not only for finding a block, but also in the form of commissions paid by users for confirming transactions and including them in blocks. Accordingly, the higher the cost of gas, the more profit the miners get.
It is worth noting that the priority of transaction verification also depends on the amount of commission per transaction. At the same time, miners are the first to choose the transactions with the highest cost of gas, which allows them to get a higher fee for fewer actions. Therefore, setting a high gas price allows users to bypass other transactions in the queue, and be among the first to be validated.
Will the high price of gas affect the stability of the network?
As the price of gas rises, Ethereum miners will be able to make more profits. However, this will make the Ethereum network unsuitable for micropayments. This in turn could lead to the network becoming impractical for many projects, as well as hindering the mass adoption of cryptocurrencies.
Gas is an integral part of the Ethereum network, necessary to control transaction rates, incentivize miners and avoid huge costs. Through the use of Gas, Ethereum has been able to create a competitive environment in the formation of fees and reduce the number of unnecessary transactions within the network. It is partly because of this responsible economy that many choose Ethereum to create new blockchain projects and conduct ICOs.