Search
Generic filters

EIP 1559 Example – What is EIP-1559?

It’s been almost a year since the Ethereum “London” update, which took place in August 2021. The upgrade contained several improvement proposals to be implemented, including EIP 1559. The upgrade had quite an impact on Ethereum gas fees. However, it turns out that many users still don’t know what this London hardfork upgrade exactly entailed. Thus, we decided to cover an EIP 1559 example fee calculation as a demonstration explaining what EIP 1559 is. As a result, you’ll finally understand this rather important update on Ethereum. First, we will answer the fundamental question of “what is EIP 1559?” so that even complete beginners can follow along. Once covered, it will help you decide if Ethereum is the chain you want to focus on for development. Also, it will enable you to handle your gas fees like a pro and even perform gas optimization in Solidity

If you want to become a Web3 developer, you should get an EIP 1559 example under your belt. After all, it will help you realize that Ethereum gas fees are still relatively high. Hence, considering other EVM-compatible chains makes a lot of sense. Fortunately, there’s the ultimate Web3 backend platform, Moralis, at your disposal. This “Firebase for crypto” platform is all about cross-chain interoperability, enabling you to deploy killer dapps (decentralized applications) across multiple chains with the same code (with a few minor tweaks in some cases). You can start focusing on blockchains such as Polygon, Avalanche, and BNB Chain, where transaction fees are affordable. However, as you manage to grow your budget, you can easily deploy the same dapps on Ethereum. So, create your free Moralis account and use it to create a Moralis dapp in minutes. Although, make sure you first cover our EIP 1559 example. 

What is EIP-1559?

As mentioned above, EIP 1559 is a hardfork upgrade to Ethereum’s blockchain known as the “London upgrade”. The implementation happened in August 2021. It had a huge impact on the market mechanism regarding the payment for transaction fees. This Ethereum improvement proposal (EIP) was initially submitted by Vitalik Buterin, one of Ethereum’s founders. His intent was to reduce the cost per transaction. He planned on doing this by not paying miners the gas fee that users were bidding on in the old Ethereum transaction fee mechanisms. Vitalik expected lower transaction fees if users were to overpay for gas less often. Hence, implementing a base fee was necessary.

The implementation of Vitalik’s proposal was successful. While it didn’t significantly affect lowering the transaction fees, it did make it easier for users to predict fees. We cover the gist of EIP 1559 as we move forward, and we cover the improvement proposal more thoroughly in our EIP 1559 example. However, we need to make sure you understand Ethereum gas first.

Note: Want to learn about using smart contracts to determine the current price of Ethereum gas? Check out the video at the end of this article. There, you can check out the complete code for an EIP 1559 example!

What is Ethereum Gas?

To properly understand what EIP 1559 is and to get the most out of the EIP 1559 example, you need to know what Ethereum gas is. With the Ethereum network’s basics in mind, you probably know that EVM is a global processor and that miners power this decentralized processor. Accordingly, powerful computers execute EVM smart contracts. Hence, they implement Web3 contracts’ effects via new blocks to the Ethereum blockchain. In addition, we must point out that we use units of gas to measure the usage of EVM. As such, the consumption of gas increases if usage intensifies.

In short, gas is basically the fuel for EVM. But to make things a bit confusing, gas is also the unit of measure for that fuel at the same time. Furthermore, Ethereum gas is denominated in gwei, or gigawei (1 gwei = 0.000000001 ETH = 10-9 ETH). As far as the Ethereum gas fees go, they are fees that users need to pay to compensate for the computing energy required to execute transactions.

Most people have no idea that each specific operation on the Ethereum network has a fixed price in gas. Ethereum’s yellow paper clearly defines this. So, it is not the price in gas that changes, but the price of gas, which fluctuates in line with the supply and demand. Hence, the value of one gas transaction expressed in gwei is constantly changing. In addition, the entire amount of gas utilized to execute the set of transactions included in any given block affects the size of that block. Thus, each block’s capacity (the amount of data it holds) is determined by the computation of involved transactions.  

The Gist of EIP 1559

Now that you know what Ethereum gas and what gas fees are, we can cover the gist of EIP 1559. Here are the key changes to the legacy gas pricing model:

  • EIP 1559 introduced better transaction fee estimation (it made transaction fees more predictable).
  • The London update made transaction inclusion quicker in general. 
  • EIP 1559 also introduced offsetting the ETH issuance. It does this by burning a percentage of transaction fees (base fee).
  • After the update, Ethereum transactions have a base fee, which is calculated by the network. Its calculation is based on the demand for the current block’s space. 
  • The base fee is burnt (destroyed or taken out of circulation) entirely. As such, there have been days when Ethereum was deflationary. 
  • EIP 1559 also introduced a tipping system via priority fees. Users who want their transactions to be prioritized can use this option. These fees go to the miners, hence the name “tip”.
  • The London hardfork also implemented “maxFeePerGas”. This feature enables users to set how much they are willing to pay for the execution of their transaction. Hence, they are able to ensure not to pay more than the market price for gas (“baseFeePerGas”). As such, any extra paid fee, minus their tip, is refunded to the users.

Nonetheless, this image neatly presents some of the most important aspects of the EIP 1559 update:

EIP 1559 Example – How Gas Fees Work and How to Calculate Them

Knowing what Ethereum gas fees are, we are ready to learn how they work. The latter will enable you to make the most out of the EIP 1559 example calculation coming up. Let’s start by pointing out that Ethereum uses the proof-of-work (PoW) consensus mechanism. Hence, miners and their computational power play a vital role. They verify and process transactions using powerful computers. After all, every transaction needs a miner to be verified and added to the current block. Logically, miners get some sort of compensation for their work. If nothing, their electricity bills are not going to pay themselves.

With that in mind, you can look at network gas fees as a reward for miners. In fact, the legacy system was precisely that. However, after the EIP 1559 update, only tips go to the miners. However, the base fee amount still depends on two things:

  1. The network’s congestion determines the current price of gas in gwei.
  2. The size of a contract you are trying to execute and how quickly you want it executed. This determines the amount of gas needed. 

We believe that looking at an EIP 1559 example transaction will help you understand how Ethereum gas fees work. So, let’s assume that “Joe” wants to send one ETH to “Lisa”. If he wants Lisa to receive one ETH, he needs to have one ETH, plus the amount for Ethereum gas fees. For the sake of this example, let’s assume Joe has enough ETH. Hence, Lisa will receive one ETH while the rest (base fee + tip) is split, as displayed in the image above.        

How are Gas Fees Calculated – EIP 1559 Example

Before the London upgrade, gas fees were calculated using a so-called “first-price auction model”. The latter is now known as the legacy gas pricing model. The main problem of the legacy pricing model was its lack of accuracy. Thus, the actual gas price and the calculated gas price would often not match. When that deviation accrued during the submission of the transaction request and the actual transaction, it caused issues for users. As such, many users ended up paying gas fees for nothing. On top, transactions often got stuck for extended periods. Fortunately, EIP 1559 solved those issues. However, it also introduced additional complexity. So, the calculation of the total transaction fee after EIP 1559 follows this equation: 

Total transaction fee = gas units (limit) x (base fee + tip)

Let’s dissect the above equation:

  • Gas units, or gas limits, are defined in the appendix “G” of the Ethereum yellow paper. 
  • The base fee (introduced with EIP 1559) is the minimum price per unit of gas for inclusion in the current block. Moreover, the network calculates the base fee according to the current demand for block space.
  • The priority fee (tip) is there for users to give their transactions priority. Moreover, it is also part of the fee that rewards miners.

EIP 1559 Example Calculation

Now, let’s use the above equation and the previous transaction example (Joe and Lisa) to calculate the Ethereum gas fee. To accomplish this, we need to know the exact values of all variables entering the equation. Therefore, we need the gas limit, the base fee, and the tip. For the sake of this EIP 1559 example, we can assume the current base fee – let’s say it’s 100 gwei. Also, let’s set Joe’s tip at ten gwei. Nonetheless, we use the Ethereum yellow paper, which tells us that the gas limit for transactions is 21,000. Finally, we can put it all together:

21,000 x (100 + 10) gwei = 2,310,000 gwei = 0.00231 ETH

Looking at our EIP 1559 example calculation, Joe needs to have 1.00231 ETH in his wallet to send one ETH to Lisa. Moreover, the total transaction fee of 0.00231 ETH includes a 0.0021 ETH base fee and 0.00021 ETH tip.

Ethereum Gas Prices Estimating Tools

After the EIP 1559 update, gas fees prediction is a lot more accurate. That’s mainly thanks to using the previous block’s details instead of the current block’s. Furthermore, this also enables everyone to calculate gas fees for their EIP 1559 example transactions. For one, you need the above equation. You also need the Ethereum yellow paper and the Ethereum gas tracker on Etherscan. The combination of these tools will enable you to properly estimate gas fees. Another fantastic tool is MetaMask. This most popular Web3 wallet is regularly updating its UI. As a matter of fact, their team recently implemented some EIP 1559-related changes:

Nonetheless, to properly determine the current Ethereum gas price, you can also use your Solidity basics in combination with a particular smart contract. Then, you can use the latter as a tool in other smart contracts and dapps. This is where Remix can help you a lot. If you’d like to learn more about using smart contracts to determine the current price of Ethereum gas, check out the video below (14:08). Moreover, the entire code used in the EIP 1559 example below awaits you on GitHub.

EIP 1559 Example – What is EIP-1559? – Summary

At this point, you know that EIP 1559 is one of the Ethereum network’s updates. The implementation of EIP 1559 happened in August 2021, mainly focusing on the mechanism of Ethereum gas fees. Further, it changed the calculation and distribution of gas fees. This made gas fee estimation a lot more accurate and started burning the base fee portion of the fees. Herein, we also covered an EIP 1559 example calculation. Finally, you also learned about some excellent tools that can help you calculate gas fees.

With the knowledge obtained in this article, you are ready to take your blockchain development journey further. So, use the Moralis YouTube channel and the Moralis blog to explore other aspects of this disruptive technology. For instance, some of the latest articles will show you how to mint game assets as NFTs, build a decentralized autonomous organization (DAO), build a Solana token dashboard, create your own metaverse, create a BNB NFT, build a play-to-earn (P2E) game smart contract, or a Uniswap DEX clone. Furthermore, these are also the outlets to learn about crypto topics such as dynamic NFTs, NFT-based memberships, fractional NFTs, SPL vs ERC20 tokens, etc.

We strongly encourage you to take on some more advanced example projects. These include building a Web3 Twitter clone, Web3 Netflix clone, and Web3 Spotify clone, to name a few. On the other hand, if you want to become a blockchain developer with confidence, you need to take a more professional approach. As such, you ought to consider enrolling in Moralis Academy.

May 15, 2022
Become a Moralis Mage
Get the latest information about Moralis Web3 in your email
Search
Generic filters
Related Articles
Become a Web3 Expert
Subscribe to our newsletter and get our E-book Web3 Speed run for FREE