Gas – What is it? Are there ways to save on it?

DeFi Dec 5, 2021

Key takeaways:

  • Gas is the unit that measures the amount of computational effort required to execute operations on Ethereum. It is paid by the user to the miners.
  • The $ value of gas is calculated as the multiplication of gas amount, gas price, and Ether price.
  • While gas is unavoidable when using Ethereum network, there are ways to save gas costs.

Introduction

Many people settled their very first crypto purchase on the second biggest coin, Ethereum, and find themselves losing money when transferring the asset between platforms or wallets. Some may get confused or even frustrated since nowadays the commercial banks and financial institutions charge little to no fees for transferring assets among accounts. Why do crypto transfers cost and where does the money go?  People may have that question in mind before they get to know the essential elements of the Ethereum network – gas.

What is gas?

Gas to Ethereum refers to the unit that measures the amount of computational effort required to execute specific operations on the Ethereum network. While transaction fees for Bitcoin are voluntary, gas is mandatory for Ethereum network to operate.

The logic behind gas is that each Ethereum transaction requires computational resources to execute. This is inherent to the proof-of-work consensus mechanism, which is used by the Ethereum network. To compensate the miners who provide the computational resources, a fee is required to conduct a transaction. Gas is the fuel to the Ethereum network, in the same way that a car needs gasoline to run. And gas fees are basically transaction fees that users pay to miners on Ethereum to have their transactions included in the block.

Gas fees are paid in Ethereum’s native currency, Ether (ETH). Gas prices are denominated in gwei, and each gwei is equal to 0.000000001 (10-9) ETH.  So instead of saying the gas costs 0.000000001 ETH, we can just say the gas fee is 1 gwei. The word “gwei” means “giga-wei”, while wei is the smallest unit of ETH and one wei equals 10-18 ETH. Below is a table of the denominations of ETH. In reality, ETH and gwei are the denominations people encounter the most while other denominations are rarely seen on most occasions.

How are gas fees calculated?

Gas fees are basically calculated with a simple formula:

    $Gas fee = gas amount * gas price * token price

For example, if gas amount is 10,000, gas price is 1,000 gwei, ETH price is $4,000, then the gas fee for a transaction $gas is calculated as below:

    $gas = 10,000 x 1,000 x  10-9 x $4,000 = $40

The Ethereum network works on a standard supply and demand mechanism. When a user submits a request on Ethereum, he/she is competing with all other submitted transactions for a miner to validate his/her request and be included in the current blockchain. There is a limit to the number of transactions per block, currently equivalent to 12.5 million units of gas. Once that limit is reached, the block is closed and created. New transactions will be processed in the later blocks.

Therefore, if there is more demand for transactions, miners will naturally give priority to requests with higher gas fees since those transactions will compensate their computational efforts better. As the number of transaction requests increases the gas fees that need to be offered to get a transaction completed also increase.

Gas fees can be high because Ethereum is one of the most used blockchains. As the demand increases, the gas fees can shoot up very quickly. Yet, Ethereum gas fees are not always astronomical. They have spiked to incredibly high levels during peak periods in the past such as the 2017 ICO boom and the DeFi summer of 2020. Both times, the number of projects developed on the Ethereum network skyrocketed, bringing congestion to the network. In many instances, Ethereum gas fees can be outrageous for most use cases. However, rising gas fees demonstrate that there are real use cases for Ethereum.

For users, if they would like their transactions to be processed faster, they can choose to pay more gas fees. Wallets like MetaMask enable users to interact directly with the Ethereum network, choosing the amount of gas they wish to pay. Users also have the flexibility of customizing the gas fees they are willing to pay for each transaction by adjusting the gas limit and gas price for the transactions.

What is gas limit?

If you have ever tried to configure your own gas fees for transactions, you will encounter the phrase “gas limit”. So, what is the gas limit?

Gas limit refers to the maximum amount of gas you are willing to consume on a transaction. For example, if you put a gas limit of 20,000, that means the maximum gas units you are willing to pay is 20,000. If the gas price is 32 gwei per unit, then the gas fee cannot exceed 20,000 x 32 = 640,000 gwei. A standard ETH transfer requires a gas limit of 21,000 units of gas, while more complicated transactions involving smart contracts require more computational work, so they require a higher gas limit than a simple payment.

When you specify more gas than the transaction requires, the remaining would be returned to you. For example, if you put a gas limit of 500,000 for an ETH transfer, the transaction would consume 21,000, and you will get back the remaining 29,000. However, if you specify too little gas, for example, a gas limit of 20,000 for a simple ETH transfer, the transaction will consume your 20,000 gas units attempting to fulfill the transaction, but it will not complete. The network will then revert any changes, but since the miner has already done 20,000 gas units worth of work, that gas is consumed, and you get nothing in return. So be extra careful on offering less gas than it typically requires when performing a transaction.

How does London upgrade affect gas fees?

In August 2021, the Ethererum network had the London upgrade. The upgrade introduced a new protocol called EIP-1559, and it reformed the gas fee market. The implementation of EIP-1559 made the transaction fee mechanism more complex than before, but it has the advantage of making gas fees more predictable.

Prior to the London upgrade, gas fees are essentially price auctions, where transactions offering higher gas will get processed quicker. And the way gas is calculated is straightforward. For example, if Alice were to pay Bob 1 ETH, gas limit is 21,000, and the gas price is 150 gwei, then the total fee would have been:

    gas limit * gas price = 21,000 x 150 = 3,150,000 gwei or 0.00315 ETH

Alice was to pay 1.00315 ETH, and Bob was to receive 1 ETH, while the remaining 0.00315 ETH were to go to miners.

The London upgrade introduced the concept of two fee parts – base fee and priority fee or tip. Gas price is the sum of the two, meaning:

    gas price = base fee + tip

Base fee is the minimum price per unit of gas for inclusion in this block, calculated by the network based on demand for block space. Priority fee or tip is set voluntarily by the user to compensate the miners. Under this mechanism, the base fee is burnt by the network, and miners receive only the tip from the users as their compensation.

Recycling the example we used for Alice and Bob, let’s say if Alice were to pay Bob 1 ETH after the London upgrade. Gas limit was still 21,000. Base fee was 100 gwei. Alice included a tip of 50 gwei.

    gas fee = base fee + tip = 150 gwei

The total fee would be:

    total fee = gas limit * gas fee = 21,000 x 150 = 3,150,000 gwei

Out of total fee, base fee = 21,000 x 100 = 2,100,000 or 0.0021 ETH,

and tip = 21,000 x 50 = 1,050,000 or 0.00105 ETH.

So, Alice would have 1.00315 ETH deducted from her account. However, miners would receive 0.00105 ETH in this case, and 0.0021 ETH would be burnt by the network.

Fee prediction

To be eligible for inclusion in a block, the gas price must at least equal the base fee. The base fee is calculated independently of the current block and is instead determined by the blocks before it - making transaction fees more predictable for users. When the block is mined this base fee is "burned", removing it from circulation. The base fee will increase by a maximum of 12.5% per block if the target block size is exceeded. This exponential growth makes it economically non-viable for block size to remain high indefinitely. For example, if the target block size is 20 million units of gas, the following graph would give an idea of how the base fee changes with varying block sizes.

Following this table, to create a transaction on block #9, a wallet will let users know that the base fee to be added to the next block would be 12.5% higher on top of the current base fee, which is 160.2 x 112.5% = 180.2 gwei, making the fee more predictable than prior to the upgrade.

Nevertheless, to make a transaction go through, users would likely have to include a priority fee or tip. Without tips, miners wouldn’t find it economically viable to mine empty blocks, as they would receive the same block reward. Like the situation prior to the London upgrade, a higher tip will provide bigger incentives for miners to include a transaction. If users want to have their transactions get processed quicker, a higher tip will be necessary to outbid the competing transactions.

While it sounds a bit more trouble for users after the London upgrade as users will need to specify base fee and tip each, for wallets that support the upgrade, they will automatically set a recommended transaction fee (base fee + recommended priority fee) to reduce the amount of complexity burdened onto their users.

Strategies users can use to reduce gas costs

Ethereum fees continue to rise, making the network unusable at times. According to Etherscan, a simple trade with Uniswap costs $119.28 as of Nov. 22, 2021. Nevertheless, Ethereum remains the most popular network. As a matter of fact, the rising gas fees are the key indicators that Ethereum is of real use cases.

The Ethereum community is taking initiatives to reduce gas costs. L2 scaling is a primary initiative to improve gas costs and scalability. The new network upgrades to Ethereum 2.0 should address some of the gas fee issues, and the proof-of-stake model might be able to reduce the high-power consumption and reliance on specialized hardware. Many side chains have been developed with the goal of reducing gas costs while offering the same look and feel that Ethereum mainnet brings. (To learn more about Layer 2 and side chain, please read this article)

Additionally, there are strategies and technologies that can help the users mitigate their gas expenditures. Below we list a few measures that users can utilize to get smart about gas and stop spending more ETH than necessary when using the Ethereum network.

1.Plan your transaction time

Chart, line chart

Description automatically generated
Credit to YCHARTS

Ethereum gas prices can fluctuate considerably intraday as different on-chain events take place and as different parts of the world wake up and become active. Accordingly, there are certain times where, on average, gas prices are typically lower. If you take stock of these times and target them for transactions, that’s a great start on the path to lowering your gas expenses. There are many tools available for monitoring the gas price, such as:

2. Use gas simulation like DeFi saver

Traders don't know the actual gas fee until they carry out the transaction and pay for the gas. However, there is a DeFi Saver app to simulate the transactions. To run it, users just need to perform the activities they would like to do for real and then run the transactions virtually. The real-life simulation will tell you the estimated and maximum gas fee in ETH. You can then customize your entire operations to minimize the gas fee.

3. Use gas tokens

Ethereum has a storage refund system, which basically allows users to delete the storage variables and get refunds. Users can take advantage of this property by minting gas tokens when gas prices are low and then redeeming them when they are high. When redeeming the gas tokens, the users will receive a refund in ETH to help cover the gas expense. So with gas tokens, users can sort of taking a snapshot of Ethereum’s state at the time of low gas prices and then essentially unlock that state when gas prices are higher to receive an ETH refund.

Gas tokens actually clog Ethereum’s state size and lead to inefficient gas pricing, so it might be phased out in the coming years. Users do need to keep that in mind when using the gas token strategy to save up on gas fees. In the meantime, they can lower your gas expenses so don’t rule them out for now!

4. Use dApps that minimize gas

Some decentralized applications made efforts in providing gas reduction products, either explicitly or implicitly.

For example, there are Yearn’s V2 Vaults and KeeperDAO, which automate and batch users’ transactions together, so that instead of everyone having to manually pay gas fees one by one, everyone pays them together at once, which seriously lowers the gas expenses for everyone.

Another project to consider is SynFutures protocol, a futures trading marketplace for digital assets and NFTs. The platform deploys native tokens such as BNB, Matic, ETH or WBTC as the collateral, saving the trouble of swapping for stablecoins, ETH or BTC, which are the usual collateral assets and saving gas correspondingly.

5. Explore the Ethereum scaling options

Things are still early in Ethereum’s scaling solution ecosystem, but the projects already live are impressive and improving every day. You can use these solutions to enjoy instant and ultra-cheap Ethereum-centric transactions. Layer-two (L2) solutions, like Optimistic rollups or ZK-rollups, provide super-efficient infrastructure while inheriting all of Ethereum’s security guarantees. Sidechains, like Polygon or xDAI are effectively separate efficient blockchains but are specifically aligned with, and cater to, Ethereum. Trading on the scaling solutions essentially offers users very similar experiences as trading on the Ethereum mainnet while paying much lower gas fees.

Other than the measures mentioned above, some dApps offer gas rebates to their users to make up for the pain of paying high gas fees. While paying high gas might seem unavoidable on the Ethereum network now, there are ways and techniques to help users plan strategically around it to mitigate the loss caused by the high gas fees.

Want to learn more about trading fungible assets or listing your own contracts? Try out our Crypto Futures feature now in beta.

Disclaimer: SynFutures Academy does not guarantee the reliability of the site content and shall not be held liable for any errors, omissions, or inaccuracies. The opinions and views expressed in any SynFutures Academy article are solely those of the author(s) and do not reflect the opinions of SynFutures. The SynFutures Academy articles are for educational purposes or information only. SynFutures Academy has no relationship to the projects mentioned in the articles except for SynFutures, and there is no endorsement for these projects. The information provided on the site does not constitute an endorsement of any of the products and services discussed or investment, financial, or trading advice. A qualified professional should be consulted prior to making financial decisions.

Tags

SynFutures Academy

Learn DeFi · Anything · Anytime

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.