DEV Community

Cover image for Ethereum-Solidity Quiz Q25: What is gas in Ethereum?
MihaiHng
MihaiHng

Posted on

Ethereum-Solidity Quiz Q25: What is gas in Ethereum?

Gas is the unit used to measure the amount of computational effort required to execute operations on the network.

1. Why does Gas exist?

Because every transaction must be processed by thousands of nodes globally, Gas serves two vital purposes:

Preventing Spam: It ensures that users can't clog the network with infinite loops or millions of useless transactions for free.

Resource Allocation: It compensates miners/validators for the electricity and hardware power they use to secure the network.

2. How the Price is Calculated

Calculation formula:

Total Fee = Gas Units * Gas Price
Gas Price = (Base Fee + Priority Fee)

https://etherscan.io/gastracker

Gas Units: The "amount of work." A simple transfer usually costs 21,000 units, while complex smart contracts (like swapping on Uniswap) cost much more.
Base Fee: The minimum price per unit to get into a block (this is set by the network and is burned).
Priority Fee (Tip): An optional extra payment to validators to "skip the line" and get your transaction processed faster.

3. Gwei:

Gas prices are denoted in Gwei, which is a tiny fraction of 1 Ether.

1 Gwei = 0.000000001 ETH(10^-9ETH).

Top comments (0)