The Etherium 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’ll take an in-depth look at what Gas is in Etherium, talk about what it’s used for, and how to optimize its costs.
Gas in Etherium
We’re all used to the fact that you have to pay a fee to miners for their services to verify transactions and support the network in order to make transactions in 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. Pay more – the transaction will go faster, less – you’ll have to wait a bit.
With Etherium, it’s more complicated. The commission for transactions in the Etherium 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 its help, miners can receive a commission commensurate with their resource costs, because the more complex the transaction, the more gas it will take to perform it.
Ethereum Gas appears for any transaction that requires a fee. Specifically, gas is needed to:
make a transfer of ETH to another wallet;
to create a smart contract on the Ethereum blockchain;
execute a smart contract on the Etherium 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 Etherium 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 Etherium – 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 cost of Etherium 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.