The Developer EIP-1559 Prep Kit
Beyond being the single most viewed and discussed Ethereum improvement proposal (EIP) in the chain’s history, EIP-1559 is a fundamental change to the way that Ethereum gas fees are set and paid. In this post we’ll sort through what it will solve, what it may not, and how you can prepare.
Note that we’ll be covering the developer perspective here. If you want to learn more about the EIP as an end user, miner, or investor, there are plenty of great posts out there already!
The TL;DR
There’s a lot to cover regarding EIP-1559, and I encourage you to read on for an in depth intro to the upgrade and how to prepare, but here’s a quick summary to make sure you’re prepared:
Why should you care? EIP-1559 will introduce a more efficient system around Ethereum gas prices, which will introduce much more predictable gas prices and mining times
EIP-1559 introduces a new fixed “base fee” and “inclusion fee” to replace the current blind auction system for determining gas price
EIP-1559 will go live with Ethereum’s London hardfork at block 12,965,000 - expected on August 4th
The upgrade will be fully backwards compatible, so legacy transactions will continue to work without issue (but won’t take advantage of the benefits EIP-1559 introduces)
The “gasPrice” parameter currently set for transactions will be replaced by two new values (note: both come with reasonable defaults!):
maxFeePerGas: a cap on base_fee + priority_fee, in other words the total amount you’re willing to pay per gas
maxPriorityFeePerGas: a cap on the priority_fee specificallyeth_gasPrice will behave exactly as it does now, to maintain backwards compatibility
eth_maxPriorityFeePerGas is a new endpoint added to get the estimated priority fee required for the next block
The base fee for the next block will be accessible as a new base_fee parameter on the latest mined block
EIP-1559 is not intended to lower overall gas fees - if that’s what you’re looking for, check out Alchemy’s recently released support for the most popular layer 2 networks: Arbitrum, Optimism, and Polygon (with more to come!)
Most importantly, reach out to us if you have any questions or issues getting prepared, and we’re more than happy to help!
A Quick Primer On Gas
To understand EIP-1559, we first need to understand how gas fees work on Ethereum at the moment. If you’re already familiar with the current model of paying Ethereum gas fees and its pain points, feel free to skip this section.
Currently, the amount a user pays to get their transaction included in a new block is the product of two values: gas and gas price.
Total cost = gas * gas_price
Gas is simply a measure of how many resources a transaction uses, and is determined automatically by Ethereum nodes. The more intensive the transaction, the more gas it consumes and the more expensive it will be. (Note: this is unchanged by EIP-1559)
Gas price on the other hand, represents the amount a user is willing to pay, per gas, to have their transaction mined and is chosen explicitly by the user. The ‘correct’ gas price is currently determined by a blind auction - each user chooses the amount they are willing to pay, a miner selects the transactions with the highest gas price, and each user included in the block pays the amount they bid.
As almost anyone who’s used Ethereum can tell you, this model for picking gas price has two key problems. The first is that the gas price needed to be included in the next block can be extremely volatile, making it very difficult for a user to predict what price they’ll need to choose.
Take for example this series of blocks from June 2020, where the average gas price per block increases by 1000% for a single block:
Unfortunately this kind of swing in gas price is far from rare, and far from the most dramatic Ethereum has seen. Even more frustrating, when the price suddenly increases for an extended period of time, users can end up in a state where their transaction remains unmined for hours despite having a reasonable gas price at the point in time it was sent.
The second key problem with the current model for choosing gas price is that blind auctions are widely known to be inefficient, and frequently lead to users overpaying. There are plenty of more in depth resources on this for the curious, but consider this simple example:
User A submits a transaction with a 1000 gwei gas price
All other users submit transactions with 10 gwei gas prices
A miner selects User A’s transaction, and fills the rest of the block with 10 gwei transactions
In this case, User A paid 1000 gwei as a gas price, despite the fact that 11 gwei (or even 10.00001 gwei) would have been plenty to guarantee their transaction was mined. Purely because of the auction mechanics at play gas price, User A overpaid by a staggering 989 gwei per gas. Given the amount of gas consumed by a single transaction, this could easily mean that User A overpaid by tens to hundreds of dollars!
Clearly there is room for improvement. Enter EIP-1559.
How EIP-1559 Changes the Game
EIP-1559 replaces the old, blind auction mechanism behind Ethereum gas price with a new fixed fee model.
Instead of guessing at a volatile gas price, users will be given a set ‘base fee’ needed to be included in the next block. All users will be responsible for paying this base fee, no more and no less.
With each new block, the network will automatically adjust the base fee based on demand. For example, if a block is 100% full, the fee will increase by 12.5% for the next block. If a block is completely empty, the fee will decrease by 12.5% for the next block. If a block is 50% filled, the fee will remain the same.
Notice that the most the gas price can change from block to block is 12.5% - a dramatic improvement from the 1000% in the example above. This means not only is the gas price for the current block deterministic, gas prices for blocks shortly will be much more predictable.
One significant difference between the new base fee and the current Ethereum gas price is that the base fee is burned, rather than given to the miner. This is to prevent miners from manipulating the base fee by artificially filling blocks to drive up their own profits. Because of this, EIP-1559 also introduces the concept of an “inclusion fee” (also called a “priority fee”) which will be paid to a miner for prioritizing a user's transaction. This also addresses situations where too many transactions are submitted with a sufficient base fee. If a particular block is over-filled by these transactions, miners will select transactions with the highest inclusion fee to maximize their returns.
A side note on Uncle Risk
Many sources talking about EIP-1559 describe the inclusion fee as an optional ‘tip’ to miners, but this is actually misleading. It takes computation, and importantly, time for miners to include any individual transaction in a block. Every time a miner decides to include a transaction, delaying the broadcasting of their mined block, they incur some risk (called ‘Uncle Risk” that another miner will swoop in and mine the current block before they do. This means their block would be uncled and they would lose the mining reward (currently ~2.6 Eth). This means that a miner should never include a transaction with a 0 gwei inclusion fee, since it puts their mining reward at risk without any compensation.
One final difference that makes EIP-1559 interesting is that block sizes will have more elasticity after the change. Currently, blocks are limited to roughly 15 million total gas, no matter how many transactions are waiting to be mined. With EIP-1559 the block size can increase based on demand to roughly 2x that size, up to 30 million gas, meaning more transactions will be included. Over time it’s expected that the base fee will adjust such that blocks still typically have only 15 million total gas, but this elasticity gives miners and the network a new way to handle large, sudden increases in activity.
How to Prepare
EIP-1559 is already live on all major testnets, and will officially go live with Ethereum’s London hardfork at block 12,965,000 - expected on August 4th. If you’re an Alchemy user, this upgrade will happen for you automatically, and you’ll be able to start using EIP-1559 by changing one or two lines of code. (if you’re not using Alchemy, make sure you prepare for the fork regardless of EIP-1559, or you may experience outages!)
Fortunately, the upgrade to EIP-1559 will be 100% backwards compatible, so August 4th is not a hard deadline for adapting to the new system. All legacy transactions will continue to work as they do now, they just won’t take advantage of any of the changes the EIP introduces.
That said, updating applications to make the most of EIP-1559 is super straightforward, so we’d encourage anyone with the bandwidth to make a couple quick updates to do so. To start using EIP-1559 all you need to do is make two changes to the transactions you’re sending:
Remove gasPrice: because of the switch to the base fee model, this won’t be needed anymore!
Add two new parameters:
maxPriorityFeePerGas: a cap on the priority_fee specifically
maxFeePerGas: a cap on base_fee + priority_fee, in other words the total amount your willing to pay per gas
In reality, step 2 isn’t even strictly necessary, since Alchemy and Ethereum nodes both support reasonable defaults for each value:
maxPriorityFeePerGas: eth_gasPrice - base_fee
maxFeePerGas: maxPriorityFeePerGas + 2 * base_fee
With that in mind though, power users will likely want to adjust these values based on the priority of their specific transactions, and desire to save on gas fees. When choosing your own values, you’ll need two values to do so: the expected inclusion fee required and base fee for the next block.
To get the expected inclusion fee, there is a brand new endpoint called eth_maxPriorityFeePerGas. Note that this endpoint is the spiritual successor to the legacy eth_gasPrice, which will continue to behave as it does now to maintain backwards compatibility.
To get the base fee for the coming block, you can simply fetch the latest mined block and look at the ‘base_fee’ value included.
A Final Note on 1559
EIP-1559 promises a number of meaningful benefits to developers and end users alike, including more predictable gas prices and mining times. That being said, there is one notable effect 1559 will not have: lower overall gas fees.
The high fees that Ethereum users have become so familiar with are a function of the limited capacity of the Ethereum network itself, and the overwhelming demand for submitting transactions. Unfortunately nothing about EIP-1559 will change these factors - but it was never intended to! That is where layer 2s and ETH 2.0 come into the picture.
So, if lower overall fees are what you’re looking for, definitely check out Alchemy’s recently released support for the most popular layer 2 networks: Arbitrum, Optimism, and Polygon (with more to come!).
In the meantime though, EIP-1559 will help make fees quite a bit more predictable and life quite a bit better for Ethereum developers and end users alike.
Planning to take advantage of EIP-1559 but still not sure how?
Reach out, and we’ll be happy to help!
Related articles
Fostering an Open Ecosystem
Alchemy’s mission is to bring the next billion users onchain. Getting there will require a fast-growing ecosystem of projects working to build the future of web3.
2023 Web3 Development Report
Web3 developer activity reaches all-time-highs as new rollup frameworks and account abstraction take root.
Arbitrum Account Abstraction Workshop Series
Arbitrum and Alchemy are partnering together to bring you an exciting new educational series on Account Abstraction!