Ethereum Gas Prices: How the Mempool acts as a Competitive Market for Settlement
Gas prices are a major source of transaction anxiety for both new and experienced Ethereum users. Accurately setting transaction fees is a classic Goldilocks problem:
⏳ If you set your gas price too low, you lose transaction predictability, and you can wait hours – or days – or weeks! – for confirmation. Not to mention the risks of a stuck wallet.
💸 If you set your gas price too high, you overpay and reduce your profitability.
So, how do you set your gas fee just right and get predictable transaction performance without overpaying? Recently, our CEO Matt Cutler sat down with DeFi Dad on YieldTV and discussed how mempool competition drives Ethereum's real-time gas fee marketplace.
While every blockchain builder and crypto trader is impacted by gas, many do not fully understand how the fee marketplace operates. Read on to learn more about what drives gas prices and how mastering these concepts can help you transact on-chain with confidence.
In the world of Ethereum, gas refers to the fees one must pay to transact on the network. Gas is paid to miners to process and validate transactions. And miners are incentivized to include the transactions with the highest fees into the next block — to maximize their earnings.
Not all transactions have the same gas requirements. The more complex the transaction – and the smart contract(s) it calls – the higher the associated fees.
Gas is typically priced in Gwei — a fractional unit of ETH where 1.0 ETH = 1,000,000,000 Gwei. Anytime you transact on Ethereum, there are a few common terms that you must understand to determine the cost of a transaction:
- Gas: the computation units your transaction requires. More complex transactions require more computation and hence more gas.
- Gas limit: the maximum amount of gas you are willing to spend on a transaction.
- Gas used: the actual amount of gas used to confirm the transaction.
- Gas price: the amount you are willing to pay for every unit of gas, denominated in Gwei.
- Transaction fee: the actual fee associated with a finalized transaction, equal to gas used * gas price.
- Gas block limit: the maximum amount of gas allowed in a block.
Together, these factors determine how competitive your transaction is in the mempool and, therefore, the cost and timeliness of getting on-chain.
How Ethereum determines the market price of gas
Think of gas as the base measure of the competitive marketplace for transaction settlement. The Ethereum mainnet block time is ~15 seconds on average. And every new block contains ~150 new confirmed transactions. However, at any given moment, ~150,000 pending transactions are circulating in Ethereum's global mempool.
So... every ~15 seconds brings a fresh, real-time marketplace involving ~150,000 pending transactions competing to be one of the next ~150 transactions confirmed on-chain. If transaction finalization was determined randomly, any given transaction would have just a 0.1% chance of being included in the next block.
Fortunately, transactions are not finalized randomly. Instead, they are prioritized by miners based on their gas fee. The higher the gas fee, the more likely miners will include any given transaction in the next block. For each new block, miners generate and revise new block templates – identifying candidate pending transactions to be included. When a given miner successfully solves the next block, that block is broadcast to its peers on the network, and each of the transactions in its current block template becomes finalized (uncles and reorgs notwithstanding).
Setting gas price for your transaction
Each time a new block is confirmed on-chain, miners immediately begin constructing the next block template consisting of the highest priority pending transactions. And the competition for settlement begins anew in a characteristic stair-step fashion.
Many Ethereum users are sensitive to the price of gas. For traders, overpaying means reduced profitability. For builders, gas fees can eat into protocol margins and disincentivize users from transacting. On the other hand, underpaying for gas results in transaction delays (and hence increased slippage), failed transactions, stuck wallet addresses, and more.
To make matters worse, gas price is variable and can quickly surge — meaning existing pending transactions can suddenly become underpriced and therefore uncompetitive.
Example of the daily volatility of Ethereum gas prices.
When determining any given transaction's gas fee, you must factor in: 1) how long you are willing to wait to get your transaction confirmed, 2) current mempool competition, and 3) the rate of change in gas prices.
How long will it take for my transaction to get confirmed?
Counterintuitively, blockchain networks do not follow standard concepts of time. Instead, they measure forward progress in blocks.
A new block on Ethereum probabilistically occurs every 15 seconds — but the next block could take 5 seconds, or it could take 60 seconds, or less, or more. Rather than thinking about how long it will take your transaction to get confirmed, instead, think about how many blocks it will take your transaction to get confirmed.
Calculate Ethereum gas prices for predictable transaction performance
There are many approaches to estimating gas fees, but the most common one involves looking at the last confirmed block to get an estimate of the gas fees. But as we have discussed above, the fee market for gas takes place in the mempool. And the mempool can be a volatile – and sometimes downright chaotic.
By relying on past blocks as your source of truth for gas price, your transaction is vulnerable to becoming underpriced and uncompetitive – or overpriced and wasteful – based on sudden changes in mempool congestion.
To create a more predictable transaction experience, builders and traders can look to the current contents of the mempool to calculate transaction fees. However, gaining an accurate and complete view into of the current state of the global mempool can be difficult on your own — since any single node contains an incomplete view.
At Blocknative, we are committed to illuminating the Dark Forest and providing unrivaled transaction transparency to the ecosystem. Our infrastructure monitors and manages the complexity of the mempool — making this crucial part of Web3 available to every builder.
An Ethereum gas price API, by builders for builders
To help users transact with confidence, Blocknative is introducing our Gas Platform. It takes a fresh approach to helping builders and traders accurately estimate gas fees. Specifically, Gas Platform:
- Estimates prices based on the current contents mempool, rather than the last block.
- Makes predictions based on block estimates, not time.
- Has an easy to integrate API.
- Provides builders and traders with a rich data payload so you can make your own decisions.
- Is fully documented and actively supported.
Gas Platform is a significant addition to the ecosystem's gas estimation capabilities. By leveraging the mempool, Gas Platform provides builders and traders with an accurate, up-to-the-moment gas fee API. Our goal is to help you to quickly get on-chain, without overpaying. If you want to learn more, read our recent article Comparing Ethereum Gas Estimators: How Blocknative Gas Platform Stacks Up.
Gas Platform helps you determine what gas prices will be for future blocks and more with the following feeds:
Sample Gas Platform API Payloads
- Block Gas Estimator feed: This feed estimates gas prices for the next block based upon current mempool contents.
- Gas Distribution feed: This feed provides the distribution of gas prices in the mempool right now.
And, like all of Blocknative's offerings, Gas Platform is fully documented and actively supported. With an easy to integrate API, Gas Platform can improve transaction predictability in your application or trading strategy.
To help you consume Gas Platform, we have created Blocknative Gas Estimator — with an easy to use interface that helps you set gas prices so you get into the next block without overpaying.
Blocknative's Gas Platform is available to every Ethereum builder and trader. You can go hands-on with Gas Platform in Mempool Explorer. Or explore the Docs and create a free account to start building with Gas Platform today. And as always, if you have any questions or feedback — please join our Discord Community.