What Are Gas Fees?

Vesper Finance
Vesper Finance
Published in
4 min readNov 3, 2023

--

Whether a transaction succeeds or fails, gas fees are a constant in the world of crypto. But what are they exactly?

Overview

What Is Gas?

First and foremost it's important to understand that every transaction on Ethereum requires “Gas”. Essentially it refers to the effort required to get things done on the network. Since every action has a different level of complexity, gas costs can fluctuate depending on the task required, and the overall network usage at the time of the request.

But why exactly do we need gas?

As mentioned above, every transaction requires gas to execute. This is because those resources come at a cost in order to ensure Ethereum can't be spammed and get stuck in infinite computational loops.

In order to work out how much exactly a transaction will cost, the gas fee is determined by the amount of gas used, multiplied by the cost per unit of gas. It’s important to note that even if a transaction fails, you will still need to pay the gas fee.

Source: Ethereum

You might have also encountered the term GWEI, often referred to as the “gas price.” In essence, GWEI is a smaller unit of ETH, with one GWEI being one-billionth of an ETH, or 0.000000001 ETH. Using a GWEI calculator makes it easier to figure out the gas price at any moment, which can help you decide when to make a transaction based on whether the GWEI is high or low.

Why Do We Need Gas?

So now we know what gas is, why exactly do we need it? Put simply, it helps keep the whole Ethereum network secure by incentivizing validators to accurately process transactions. But let's first look at the initial use case of gas.

Initially, gas was introduced to deter malicious activities, such as network spamming. By setting a limit on the computational steps a transaction can use, it prevents unintended or malicious infinite loops and computational waste (any gas not used is always returned to the user).

Source: Ethereum

Validators on the other hand ensure the security of the network by verifying blockchain transactions, which is where the computing power comes from. Typically, these validators invest in specialized equipment and purchase ETH to take on this role, therefore to encourage their participation, they earn fees from transactions, which is included in the gas fees. As Ethereum operates on a proof of stake (PoS) consensus mechanism, these validators are rewarded by committing a specific amount of ETH (32 ETH) to the network.

How Are Gas Fees Determined?

While it might seem complex with terms like “gas wars,” understanding gas fees isn’t too tricky once you break it down.

When you submit a transaction, you can choose how much gas you’re willing to pay. However, setting a low gas price might mean your transaction is slower than usual or fails, as validators may prioritize others who bid higher for a spot in the next block. It’s a balancing act — bid too high and you might waste gas, but bid too low and your transaction might not go through, losing that fee.

But why does this matter?

The total gas fee has two parts: the base fee and the priority fee. The base fee is set by the protocol, while the priority fee is like a tip to make your transaction more appealing to validators so they choose you. Essentially, a higher “tip” can help you win any gas wars and ensure your transaction goes through, however, this could get quite expensive.

How Can Layer 2’s Help?

High gas fees on the Ethereum mainnet, particularly during periods of heavy network usage, have often been a massive barrier to entry for many users seeking to get involved. Layer 2 solutions like Optimism and Arbitrum were created to directly address this issue. These solutions, commonly referred to as Layer 2s or L2s, are built on top of existing blockchains and have become instrumental in increasing the efficiency of these networks.

But how?

Well, L2s are designed to process multiple transactions off-chain and batch them together before submitting them to the main chain, significantly reducing overall gas costs. They also undertake most computational tasks, such as transaction validation and smart contract execution off-chain, submitting only the final state or a cryptographic proof to the main chain. By doing this, Layer 2 solutions drastically improve scalability and increase the transactions per second (TPS) without burdening the main chain. This reduces overall network congestion and, as a result, lowers gas fees for users.

Source: Maddevs

Summary

To summarize, in Ethereum, every transaction requires “Gas,” a measure of computational effort, to execute actions. Gas fees ensure network security by preventing spam and incentivizing validators to process transactions. These fees can fluctuate based on the complexity of tasks and network demand. However, Layer 2 solutions, like Optimism and Arbitrum, offer a welcomed change by reducing the typical high gas fees of Layer 1s through processing transactions off-chain and then batching them to the mainnet. This approach improves scalability, reduces congestion, and offers a more affordable experience for users.

--

--