Lesson 2

[ EVM ] Use cases - EVM Gas Analysis

Introduce gas fees and how to monitor them. Analyzing gas data could help you understand the current situation for users who trade frequently.

What is gas?

Gas, like the need to burn fuel while driving, is critical to the recording of blockchain information and refers to the amount of computational work required to perform a particular operation on the blockchain.

Why do we need gas?

Gas also helps secure the network. Charging a fee for each operation performed on the network prevents excessive spam on the network, such as users wasting network resources by intentionally or unintentionally looping indefinitely.

Charging gas fees also gives miners more incentives. Every transaction on EVM requires resources from the miner to execute, so the user must pay a fee to the miner in return for their work.

How to provide gas?

In the case of Ethereum, when a user needs to make a transaction on the chain, the gas fee is not deducted from the token sent by the user, but from the ETH left at the user’s wallet.

The amount of gas fee expected to be paid will be indicated to the user at the time of the transaction, so the user needs to ensure that they have enough ETH in their wallet to cover the gas fee.

The payment of the gas fee on Ethereum is made with its native token ETH. Similarly, transactions on the EVM chain basically require the exchange of enough native tokens (such as ETH) in the wallet.

For example, Alice has 5 ETH in her wallet address, she wants to transfer 1 ETH to Bob, and if the transaction is crowded, Alice will have to pay 0.1 ETH as gas fee to complete the transaction. When the transaction is completed on the chain, Bob will receive the 1 ETH and Alice will have 3.9 ETH left in her wallet (5-1-0.1=3.9).

Gas fee after EIP-1559

On August 5, 2021 (12:33:42 PM +UTC), the eleventh hard fork, the London Upgrade, was activated at an Ethereum block height of 12,965,000. The most talked about community EIP for this upgrade, EIP-1559, makes significant changes to Ethereum’s gas fee mechanism.

The London upgrade focuses on optimizing the gas fee in two ways.

  • Fee allocation mechanism: from the original all to the miners, split into Base Fee (also known as Burnt Fee) and Priority fee.
  • Base Fee: Each block has a base fee that serves as a floor price and will be calculated based on the base fee of the previous block and block utilization. The base fee is a fee that users cannot regulate themselves and must pay, but it also makes it easier for users to predict transaction fees. This portion of the fee will eventually be burned and taken out of circulation.
  • Priority Fee: Paid optionally by the user, this fee is paid directly to the miner, and a high amount can be set to attract miners for users who want to speed up transactions.
  • Slack mechanism of blocks: Block slack mechanism: EIP-1559 allows for variable block sizes in the face of sudden surges in transaction demand. If the target block size is exceeded, the base fee per block will be increased a maximum of 12.5%.
    The London upgrade has made the calculation of the gas fee more complicated, but it has improved the user experience when setting the gas fee, and these mechanisms have made it possible to make the gas price smoother.

How to monitor gas fees in Footprint Analytics

Put in another way, a total transaction fee is the sum of the Base Fee and the Priority Fee, which is also the Gas Price multiplied by Usage by Txn. Gas Price is the unit price of the miner’s work, and Usage by Txn is the amount of work used by the miner.

Once we know the principles, we can analyze gas from multiple perspectives on Footprint Analytics. Analysts can use the fields ethereum_transactions and ethereum_blocks to calculate as needed.

ethereum_transactions dictionary

More table dictionaries can be found here.

Since the consumption of gas is much smaller than 1 ETH, GWei or Wei is usually used as the unit of measure. The unit of data on Footprint Analytics is Wei, and the calculation of the gas fee is obtained by multiplying receipt_effective_gas_price and receipt_gas_used.

If we want to know the base fee, we need to join the ethereum_blocks with the block_number field to get the base_fee_per_gas of the block.

How to use data to follow gas fees fluctuations

Gas is affected by current network conditions and can drive up the price of gas when transactions are frequent, so we can use Footprint Analytics’ trend charts to see how much gas is going up in the EVM chain at a given time, saving us money on unnecessary expenses.

Ethereum Gas

In addition to looking at the recent gas fluctuations, the time of day analysis can also save gas fees. The chart shows that the median and average gas price for the last 30 days is higher between 14:00 and 21:00 UTC+0, so it is wiser to avoid trading during this time.

Ethereum Median & Avg Gas Prices By Hour of Day (UTC)

The gas price is analyzed in bins, 12% of the transactions in the last 30 days have a gas price between 20 - 30 Wei, which allows the user to determine whether the price of the upcoming transaction is reasonable.

Ethereum Txn Gas Price Distribution in 30D %

Other chains which are also EVMs can be compared, and it may be smart to choose a chain with a low gas fee. However, different chains use different tokens for their gas fees, so direct comparisons are not comparable, so we need to convert them all to USD.

At this point, we can join the table with Footprint’s token price table ( token_daily_stats) and multiply the previously calculated gas fee by its daily token price to convert it to USD.

It is clear to see that the average daily gas fee on Ethereum is recently around $2, while Polygon is around $0.02, a difference of about 100 times. For users with small transaction amounts, the cost of paying a high gas fee for each transaction will be much higher, and it will be a better solution to choose a chain with low gas fees.

Ethereum Daily Avg Gas Fee in USD

Polygon Daily Avg Gas Fee in USD

Due to the nature of trading on EVM, each transaction consumes gas fees. Analyzing gas through data and understanding the current situation can be an essential task for users who trade frequently.

Disclaimer
* Crypto investment involves significant risks. Please proceed with caution. The course is not intended as investment advice.
* The course is created by the author who has joined Gate Learn. Any opinion shared by the author does not represent Gate Learn.
Catalog
Lesson 2

[ EVM ] Use cases - EVM Gas Analysis

Introduce gas fees and how to monitor them. Analyzing gas data could help you understand the current situation for users who trade frequently.

What is gas?

Gas, like the need to burn fuel while driving, is critical to the recording of blockchain information and refers to the amount of computational work required to perform a particular operation on the blockchain.

Why do we need gas?

Gas also helps secure the network. Charging a fee for each operation performed on the network prevents excessive spam on the network, such as users wasting network resources by intentionally or unintentionally looping indefinitely.

Charging gas fees also gives miners more incentives. Every transaction on EVM requires resources from the miner to execute, so the user must pay a fee to the miner in return for their work.

How to provide gas?

In the case of Ethereum, when a user needs to make a transaction on the chain, the gas fee is not deducted from the token sent by the user, but from the ETH left at the user’s wallet.

The amount of gas fee expected to be paid will be indicated to the user at the time of the transaction, so the user needs to ensure that they have enough ETH in their wallet to cover the gas fee.

The payment of the gas fee on Ethereum is made with its native token ETH. Similarly, transactions on the EVM chain basically require the exchange of enough native tokens (such as ETH) in the wallet.

For example, Alice has 5 ETH in her wallet address, she wants to transfer 1 ETH to Bob, and if the transaction is crowded, Alice will have to pay 0.1 ETH as gas fee to complete the transaction. When the transaction is completed on the chain, Bob will receive the 1 ETH and Alice will have 3.9 ETH left in her wallet (5-1-0.1=3.9).

Gas fee after EIP-1559

On August 5, 2021 (12:33:42 PM +UTC), the eleventh hard fork, the London Upgrade, was activated at an Ethereum block height of 12,965,000. The most talked about community EIP for this upgrade, EIP-1559, makes significant changes to Ethereum’s gas fee mechanism.

The London upgrade focuses on optimizing the gas fee in two ways.

  • Fee allocation mechanism: from the original all to the miners, split into Base Fee (also known as Burnt Fee) and Priority fee.
  • Base Fee: Each block has a base fee that serves as a floor price and will be calculated based on the base fee of the previous block and block utilization. The base fee is a fee that users cannot regulate themselves and must pay, but it also makes it easier for users to predict transaction fees. This portion of the fee will eventually be burned and taken out of circulation.
  • Priority Fee: Paid optionally by the user, this fee is paid directly to the miner, and a high amount can be set to attract miners for users who want to speed up transactions.
  • Slack mechanism of blocks: Block slack mechanism: EIP-1559 allows for variable block sizes in the face of sudden surges in transaction demand. If the target block size is exceeded, the base fee per block will be increased a maximum of 12.5%.
    The London upgrade has made the calculation of the gas fee more complicated, but it has improved the user experience when setting the gas fee, and these mechanisms have made it possible to make the gas price smoother.

How to monitor gas fees in Footprint Analytics

Put in another way, a total transaction fee is the sum of the Base Fee and the Priority Fee, which is also the Gas Price multiplied by Usage by Txn. Gas Price is the unit price of the miner’s work, and Usage by Txn is the amount of work used by the miner.

Once we know the principles, we can analyze gas from multiple perspectives on Footprint Analytics. Analysts can use the fields ethereum_transactions and ethereum_blocks to calculate as needed.

ethereum_transactions dictionary

More table dictionaries can be found here.

Since the consumption of gas is much smaller than 1 ETH, GWei or Wei is usually used as the unit of measure. The unit of data on Footprint Analytics is Wei, and the calculation of the gas fee is obtained by multiplying receipt_effective_gas_price and receipt_gas_used.

If we want to know the base fee, we need to join the ethereum_blocks with the block_number field to get the base_fee_per_gas of the block.

How to use data to follow gas fees fluctuations

Gas is affected by current network conditions and can drive up the price of gas when transactions are frequent, so we can use Footprint Analytics’ trend charts to see how much gas is going up in the EVM chain at a given time, saving us money on unnecessary expenses.

Ethereum Gas

In addition to looking at the recent gas fluctuations, the time of day analysis can also save gas fees. The chart shows that the median and average gas price for the last 30 days is higher between 14:00 and 21:00 UTC+0, so it is wiser to avoid trading during this time.

Ethereum Median & Avg Gas Prices By Hour of Day (UTC)

The gas price is analyzed in bins, 12% of the transactions in the last 30 days have a gas price between 20 - 30 Wei, which allows the user to determine whether the price of the upcoming transaction is reasonable.

Ethereum Txn Gas Price Distribution in 30D %

Other chains which are also EVMs can be compared, and it may be smart to choose a chain with a low gas fee. However, different chains use different tokens for their gas fees, so direct comparisons are not comparable, so we need to convert them all to USD.

At this point, we can join the table with Footprint’s token price table ( token_daily_stats) and multiply the previously calculated gas fee by its daily token price to convert it to USD.

It is clear to see that the average daily gas fee on Ethereum is recently around $2, while Polygon is around $0.02, a difference of about 100 times. For users with small transaction amounts, the cost of paying a high gas fee for each transaction will be much higher, and it will be a better solution to choose a chain with low gas fees.

Ethereum Daily Avg Gas Fee in USD

Polygon Daily Avg Gas Fee in USD

Due to the nature of trading on EVM, each transaction consumes gas fees. Analyzing gas through data and understanding the current situation can be an essential task for users who trade frequently.

Disclaimer
* Crypto investment involves significant risks. Please proceed with caution. The course is not intended as investment advice.
* The course is created by the author who has joined Gate Learn. Any opinion shared by the author does not represent Gate Learn.