Gas fees

Gas fees is an expression commonly used to refer to the transaction fees in EVM-based blockchains (like Ethereum, Avalanche C-chain, Fantom). Gas fees are paid in the blockchain's native token (ex. ETH in Ethereum, AVAX in Avalanche) and are dependent on two factors:

  • Gas cost
  • Gas price

Gas cost

Gas is the representation of the computational effort a transaction takes to be executed.

Since in a blockchain each node must independently execute every transaction, it is important to limit the amount of computational effort required from the nodes. In EVM-based blockchains each transaction has a gas cost, which is defined by its complexity and its needs for storage. Each transaction has a minimum gas cost of 21,000 gas, to which more is added as the transaction gets more complicated. For example, a swap on Uniswap costs about 190,000 gas, an ERC20 token transfer costs about 65,000 gas, adding liquidity in a Uniswap v3 pool costs about 220,000 gas. When sending out a transaction, the user (or more commonly the wallet) sets a gas limit, which is the maximum amount of gas the transaction is allowed to spend. If the transaction ends up spending less gas, the user gets a refund; if it ends up needing more gas, the transaction is reverted and the gas is not refunded.

Gas price

To decouple the cost of transacting on the blockchain from the price of the native token, gas has its own price market dependent on the demand for transacting on the chain. The more people (or bots) want to have their transaction included in a block, the more gas price will rise. The rise is due to block producers (miners or validators) preferring transaction with higher gas prices, since they get a cut of the fee. It works exactly like an auction, so who is willing to pay more gets to have their transaction included first. On the Ethereum blockchain gas price is measured in gwei, which is 10-9 ether.

Gas fee calculation

Before the EIP-1559 upgrade, the gas fee was simply calculated as the product between the gas cost and the gas price. After EIP-1559, there are two fees which add up:

  1. One is the base fee, which is set and constant for each block and is burned
  2. The other is the tip, which is variable and set by the user, depending on how fast they want their transaction included, and it goes entirely to the block producer.

These fee add up to be the final gas price which is then multiplied by the transaction gas cost to obtain the final transaction fee.

See More

All About Ethereum Gas Dashboard by @hildobby_

Owlracle is a multichain Gas Price tracker API

Ethereum Gas Tracker is a tool by UseWeb3