What happened to network fees?! Understanding how Ethereum gas works

What happened to network fees?! Understanding how Ethereum gas works

By dmngdsm | AdEx Network | 12 Jan 2021


Some of the most common questions we’ve been receiving in the first days of 2021 are ”Why is it so expensive to withdraw my earnings?” or “Why does it take $30 to stake $ADX?” or “Why do transactions fail so often?”

There is an Ethereum gas crisis happening at the moment, so we felt it necessary to explain to our community what caused it and what we and you can and can’t do about it. You can easily find plenty of well written technical articles on how Ethereum gas works, but in this one we’ll try to explain it in simple terms and with the least possible amount of complex terminology.

Ethereum and the Virtual machine

As you know, one of the main differences between Ethereum and Bitcoin is that Bitcoin can be used mainly for monetary transactions, while on Ethereum you can add complex conditions to those transactions. You add those conditions in self-executing smart contracts which power all the Ethereum ecosystem dapps, AdEx Network included.

This is an oversimplification but you can think of smart contracts like small computer programs; computer programs need to run in an appropriate environment - a computer. In computing, a virtual machine is an emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer.

The Ethereum virtual machine (EVM) is the virtual machine, in which all the smart contracts operate оn Ethereum. It is a simple yet powerful Turing Complete 256-bit virtual machine. Turing Complete means that given the resources and memory, any program executed in the EVM can solve any problem.

Does this sound feasible? Here comes gas.

The EVM and gas

One of the main differences between the Ethereum virtual machine and standard computing environments is that it is decentralized and everything that happens on it is public and verifiable. This is because it is distributed on Ethereum nodes all over the world. Ethereum miners perform all the important tasks of verifying and processing transactions and basically power the Ethereum virtual machine.

Do they do it out of goodwill and general love of decentralization? Well, certainly, but also to earn network fees as an income in exchange for their computational power and effort.

Still no idea what gas is? Coming any moment, we promise!

The car analogy

vY4dXnEDBZ_H-9ecEydTtZNsMLypevSyea0HRkxncskH9OVXTBKBx0MZCXZL7bnkw6rv7obaYcsmXAIBty18a6Nv9WzxTYzPr0OcoENYgQinUvVMqhutAzG12cthRgx18f_jkE2t

In a popular analogy you can think of a road trip. To drive your car to your destination you need gas for which you pay in your local currency. It is very similar with smart contracts. Gas is the amount of computational power required for smart contracts to run on the EVM and it is paid in Ether (ETH).

More specifically, gas is set in Gwei per 1 gas, a one-billionth of an Ether (1 Gwei equals 0.000000001 or 1/10^9 ETH)

Then why do you need “gas” if you pay in Ether eventually?” The gas system was invented in the original Ethereum yellow paper to incentivize miners to execute smart contracts.

Each and every line of code and each operation in Solidity, the computer language used for writing smart contracts for Ethereum, requires a certain amount of gas to be executed. You can see this chart of the Ethereum yellow paper for a rough idea of what some operations cost (note that some of the costs were updated with subsequent forks during time):

cE5fhNKtF26nHPIz9rVeolyG2bksW-VMTni0zd_zNEmMfzm8G5EyaZfbkppwBkrgUWJC8Xw81wZk48TvebuQl6aHN6ji7sUvnh1syEvIk5e9f5PsHE10gB8dmhw4Nj__LnXhPWMd

Gas in practice

But how does gas actually work? When you prepare to sign a transaction on Ethereum, you are about to interact with a smart contract or an address. You should specify:

  • Gas limit - what is the maximum amount of gas you are willing to spend on this interaction;
  • Gas price in Gwei - how much are you willing to pay for gas

When you multiply the gas limit you have set by the gas price you get the cost of your transaction in Ether: e.g. 210,000 gas limit X 50 Gwei gas price = 0.0105 ETH

!Handy tip - you can use this Ethereum gas calculator to calculate gas costs.

“Bollocks! I’ve never done this in Metamask before…”

Yes, you have. Well, not you, technically, but Metamask has done it for you. Since this system is kind of complicated, most wallets do it for you. But how do they know how much you are willing to pay for gas?

8_vr56UdpTm-bke82qS8ZdCoMefzX0Nr6PX_ObTpSjlp9d-BVe7lUwafElnw6mjgZuQmW1hGYhMDBaagZ6OdU1MWM8YcMbprOdam5hRWZFtaeH4JGRWQZ2SIYn9MHm8K3r2Xn5vLaCZneJOs8wFhuF4DGHvDHHdcYASZOo9LdltUx5TqPWpG40KAVCGMUrM-fklNtXbBT0UBpSxQ6QyqDhOdxtSPuRCTz1pQJOoDjciQqAWiriWXS8PpWMY9LAQ_hEEeNPVWKkxMiowE

As you know, the number of operations and transactions that can be executed per Ethereum block is limited, so there is a competition between pending transactions. Since miners are the ones who run the operations, they set the current gas price for which they are willing to process pending transactions. Gas price is determined by the competition for pending transactions. The more transactions there are to be processed, the more competition, resulting in a higher price.

Usually gas price revolves around 50 - 80 Gwei, but when there is a really stiff competition, it can rise to more than 150 Gwei.

Autumn 2020 gas crisis

_diOGICHq33kLaSvbg0PFsyLdVupKF1NRck30mAFKDrzw5QcL0zJXzv7HA7fnJ1nyCHPuH4hGnnp0FRRvXmJXSuFrfZ04uhJ4Ztdb6jVQv-bIDV_4JM9bRx6luBiGnw8r8uFTQjh

Remember how back in September 2020 everyone was complaining again about gas prices skyrocketing? This was the yield farming season and following SushiSwap, new emoji coins and farms popped up every few days or so. There were few new automated market makers (AMMs) and total value locked (TVL) in decentralized finance (DeFi) DeFi jumped to more than $10 Billion.

Now just imagine how many people started playing around with smart contracts, connecting to different AMMs and farming tokens - the competition for each block soared and so did the gas price.

The other way to name this is “Network congestion”. When a network congestion occurs, very often, even if you are willing to pay the larger gas price, your transaction may not pass because of the huge number of other pending ones.

AdEx Network’s staking incentive was live during this gas crisis so our stakers felt it too. This is why we invented the gasless staking feature available today too.

Here is how it works:

When you go to the Gasless Staking page, you will receive a unique address for your gasless staking account. You can send as much ADX as you wish to this address from other addresses or exchange accounts. When there’s a minimum of 10,000 ADX deposited, you can click “Stake” and that amount will be staked without gas fees. Read more here.

Winter 2020/21 gas crisis

C4o7i6vDjbyPmWDQRCj5UiAQjXV1eGwAuHVLWF-_YKyyhO0vZgzKdhFF5Ok1J0JRxNcws3fgzbL1yKCT7JzZmSfLXoY02bfXvbO3zHXipAGToNBnpKJVGUE9Wsf8ZN8JIDYMCMN-

The gas crisis we are experiencing right now is somehow different from the one back in September. Yes, in the last days of 2020 there were days when gas price reached 190 Gwei and more, as there were a lot of transactions following Bitcoin and Ethereum’s spikes. However, in the first weeks of 2021 prices stabilized with an average price of ~80 Gwei at the time of writing this post, but yet transaction fees keep being too high.

If you’ve read carefully along, you probably already know that it is because of the Ethereum price rally. ETH price has so far doubled since the beginning of December which basically means all transaction costs doubled, no matter the load of the network.

What can we do about that?

JDfhwuABNKsdZOVIwgHLiFu-PDFEbX3kBeJ0AV3coN-u-OTKGuxbbNcupCGf87l0t_gr_ZszSz4xsI8TfNnOyRKcIKS5naLFr-G8zgCSM2HVKuZmIrEL8yD_Fh7H8s-rsf6P8Ldp

Unfortunately, the answer is “Not much”. As long as Ethereum works as a Proof-of-Work system, network congestion and high prices during bull runs will be inevitable. Ethereum 2.0’s Proof-of-Stake is expected to bring the desired scalability of the network, but we’ll have to wait a bit before it arrives.

However, it is not in our style to finish an article on a low note, so there’s some good news after all. We are constantly developing different improvements of both our advertising and staking platforms, so that our users don’t feel the gas burden when using them:

  • On our advertising platform, the whole gas concept is hidden for better user experience - the contracts are highly optimized and you pay for gas prices in DAI without even having to think about it.
  • On our staking platform you can save on gasless staking.

While you cannot control ETH’s price or the network’s load, there are some small hacks you can utilize to live an easier “Etherean” life:

Congrats! You now know more about how Ethereum gas works. If you want to get even more into detail, we recommend Blockgeek’s Ethereum Gas article and this article on Steemit.


Interested in AdEx Network? Follow us:

Discord | Facebook | Twitter | Reddit | GitHub | Telegram


dmngdsm
dmngdsm

I mostly enjoy the Internet, books and BJJ. Doing marketing and communications at @AdEx_Network . More about me at http://ivanmanchev.com, http://instagram.com/damngoodism


AdEx Network
AdEx Network

AdEx is trust-minimized solution for digital advertising that reduces ad fraud, improves ad budgets and protects user privacy. The AdEx platform is built on the Ethereum blockchain to connect publishers and advertisers without intermediaries on a decentralized ad exchange. We introduce real-time reporting for both parties and enable payments per impression with no withdrawal threshold for publishers. https://www.adex.network

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.