Mohammed Arbaaz Shaikh




Understanding Gas in Ethereum

Mohammed Arbaaz Shaikh's photo
Mohammed Arbaaz Shaikh
·Jan 23, 2021·

5 min read

Ethereum is more than just a cryptocurrency. The Ethereum Blockchain serves as a platform where you can build and deploy decentralized applications or DApps. These DApps are governed by Smart Contracts, which are basically If-This-Then-That rules that help to validate and verify transactions.


A transaction in Ethereum is not just limited to transfer of Ether (Ethereum’s native cryptocurrency). Transactions in Ethereum can also be operations that are performed by Smart Contracts. When you interact with the Ethereum Blockchain in any way to modify or update the state of Ethereum Network, you are essentially executing a transaction.

Ethereum Virtual Machine

A Virtual Machine is a machine that emulates a normal computer but isn’t physically present on the base host. Ethereum Virtual Machine is no different. EVM runs on every Ethereum node and is responsible for executing transactions. However, executing these transactions on the Ethereum Virtual Machine requires consumption of resources and hence, it comes at a cost. We refer to this cost as Gas in the Ethereum world.


Just like your car consumes gas to go from place A to B, operations and computations on the Ethereum blockchain also consume gas to execute. Every Smart Contract written in Solidity comprises of some lines of code. And every line of code consumes gas to execute. The amount of gas required by a computation is different for different operations. For example, an addition operation may require x units of gas, a multiplication operation may require y units of gas, etc.

The operations of smart contract are executed by miners on the blockchain. So, the gas cost of all transactions and operations is paid to the miners. In a way, the concept of gas is similar to the concept of transaction fees in Bitcoin, which is also paid to the miners.

Gas is measured in terms of Gas units, which can be converted to Ether to calculate the price. The reason why a separate entity (gas) was introduced to measure the computational efforts needed to execute a transaction instead of Ether itself, is because of the high volatility of the price of Ether. Having a fixed gas price solves that problem of determining the amount of Ether needed as fees.

Gas Price Limit

Just like Bitcoin’s transaction fees, the sender of an Ethereum transaction can specify the maximum gas they are willing to pay for the transaction to go through. If this gas limit is set too low a value, no miner will pick that transaction and it will not get executed. At the same time, if the maximum gas limit is set too high, the sender will be overpaying the miners for a relatively less amount of computational effort. So, how to know the ideal gas price limit for a transaction? is a website that suggests gas price at any moment in the network. It recommends Gas prices in Gwei that will ensure that your transaction goes through.

Gas Significance

Since every transaction and operation in Ethereum requires some gas cost to execute, it enables Smart Contract developers to write efficient code with minimal operations (and thus minimal gas price). This also adds an additional layer of security to the network and protects it from any entity with malicious intention of clogging the network.

This is because if an entity tries to clog the network with code entering an infinite loop, the entity will quickly run out of gas to pay for each operation and the code will stop executing. It keeps both users and miners safe from bad code.

For any questions, feel free to reach out on Twitter or Instagram

Until next time.

Did you find this article valuable?

Support Mohammed Arbaaz Shaikh by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
Share this