What is Gas?

Gas is a unit used for measuring the amount of computational effort required to perform specific actions on the Etheruem blockchain.

The name itself hasn't been chosen by accident. Similarly to gasoline fueling a car and allowing it to drive, gas on the Ethereum network fuels transactions and allows them to perform different operations.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9c578aab-31da-4f44-ad07-9cd0f2fa6abd/Untitled.png

Every operation on the Ethereum blockchain, or to be precise on the Ethereum Virtual Machine (EVM), has an associated gas cost. For example: adding 2 numbers costs 3 gas; getting the balance of an account costs 400 gas; sending a transaction costs 21,000 gas.

Smart contracts usually consist of multiple operations that together can cost even hundreds of thousands of gas.

What is interesting is that the gas cost by itself doesn't tell us how much we have to pay for a particular transaction. To calculate the transaction fee we have to multiply the gas cost by gas price.

The gas price is measured in gwei—a smaller unit than ether where 1 gwei equals 0.000000001 ETH. We can think about it as major and a minor unit similarly to dollars and cents.

As an example, let's say we want to send a simple Ethereum transaction and the ETH price is at $1,800. Most of the popular Ethereum wallets such as Metamask estimate necessary gas prices and allow us to choose between fast, medium and slow transaction confirmation speed. Let's assume that the wallet estimated the gas price to be set to 100 gwei if we want to have a change of having our transaction confirmed within the next minute.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9ad10157-a1f7-4697-b469-2a41613b0170/Untitled.png