Optimism 101: How Gas Works on Optimism

Blocknative Ethereum Web3

Optimism is an Ethereum Layer (L2) scaling network. It differentiates itself by increasing Ethereum’s transaction throughput while decreasing the cost of transacting on the network.

This article will cover the 101 basics of Optimism, Optimistic Rollups, and OP Mainnet.

The high-level TLDR on Optimism

First thing’s first, Optimism’s OP Mainnet is a layer-2 (L2) network.

Layer-2 networks sit on top of an underlying blockchain protocol — in the case of Optimism it sits on Ethereum. The L2 (OP Mainnet) relies on the Ethereum mainnet (layer 1) for settlement, consensus, and data availability.

Base is fully EVM compatible. EVM = Ethereum Virtual Machine. This is just a fancy way to say Optimism uses software that’s compatible with Ethereum networks. Optimism has a vision for a “Superchain” — a network of OP Chains built with the OP Stack.'

OP is the governance and incentive token for Optimism.

Base is the largest example of an OP chain. Other OP Chains include Zora, Mode, Fraxtal, and Redstone. You can view a full list of OP Chains here.

How do network fees on Optimism work?

We’ll keep it simple. OP Mainnet is designed to be EVM compatible, meaning it uses the same code as Ethereum and behaves as much like Ethereum as possible.

OP Mainnet transaction fees have two types of fees: Execution Gas and L1 Data. The total transaction cost is the sum of the two. Let’s break down each.

Execution Gas Fees

The execution gas fee mirrors a transaction on Ethereum, equal to the amount of gas required, multiplied by the transaction’s gas price. OP Mainnet uses the EIP-1559 mechanism (just like Ethereum) to set the base fee for transactions. The transaction cost is the sum of the base fee plus an optional and additional priority fee.

The gas on OP stack chains will exactly match gas on Ethereum. For example, if a transaction costs 120,000 gas on Ethereum, it will cost 120,000 gas on OP Mainnet. The benefit of OP Mainnet is that the gas price is much lower, so the transactor ends up paying less.

It’s important to properly estimate the cost of a transaction before submitting it to the network.

This is where Blocknative’s Gas Estimator comes in. Blocknative makes it easy for developers to accurately predict their priority fees. With more accurate price predictions, developers can safely and reliably execute smart contracts so they can focus on what they do best…building.

Base Fee

The base fee is the lowest amount that a transaction has to cover to be included in a block. In order to be included, the transactions must specify a maximum base fee higher than the block base fee. The fee that actually ends up being charged is the block base fee, regardless of whether the transaction specifies a higher maximum base fee.

There are only a few small differences between the Ethereum base fee and the OP Mainnet base fee. These differences shouldn’t affect your transaction experience, but you can learn more about what parameters separate OP Mainnet from Ethereum here.

Priority Fee

Priority fees are paid on top of the base fee to speed up the transaction. It is an optional add-on, just like a tip in any other service industry. You can set the priority fee to 0 if you don’t want to pay for a priority fee.

Keep in mind that chains in the superchain sequencers prioritize transactions with a higher priority fee (obviously). Higher priority transactions will be executed faster, so if transaction fee is important to your application, it is important to set a high priority fee, especially during busy transaction periods.

Users can employ an RPC method to estimate the correct priority fee amount to speed up a transaction.

L1 Data Fee

This is the only part of the transaction fee that differentiates from the Ethereum transaction fee. because the transaction data for all OP Mainnet transactions must be published Ethereum, an L1 Data Fee is accounted for.

Why is data published to Ethereum? It ensures transaction data is available for nodes to download and execute.

The L1 Data Fee amount is determined based on the current base fee on Ethereum. However, with the Ecotone upgrade, OP Stack chains can now enable blobs to determine the L1 data fee.

Gas prediction can get complicated, because L1 fees will vary based on the current transaction volume on the L1. Users can avoid extraneous costs by submitting transactions during low volume periods — and leverage gas prediction tools to assume when gas is lower.

L2 fees are also prone to fluctuate based on transaction volume. An improvement proposal — EIP-1559 — was passed in 2021 to improve volatility to and prevent gas fees.

EIP-1559 + gas fees

Ethereum Improvement Proposal (EIP) 1559 is an upgrade that improves how Ethereum calculates and processes gas fees.

The outcome:

  • Increased efficiency for ETH transactions with block-base fees and sender-specified max fees
  • previously, ETH users bid on gas prices to better incentivize miners in periods of high or low network congestion.
  • there are two components: a "base fee" to pay for regular transaction speed, and an optional "tip" to speed up transactions. Base fees are standard processing and auto-calculated and predictable thanks to Blocknative’s Gas API.

You can think of gas fees like traditional delivery services. When you buy something online, you can pay for standard shipping or express shipping. During busy seasons like holidays, delivery services may increase fees to cover the cost. That cost affects all customers equally.

Previously, Ethereum had no standard fees, forcing users to guess how much to pay. That’s no longer the case.

EIP-1559 changes fees from a first-price auction to a fixed-price sale. There is a maximum gas price set by users so they know how much they have to pay to fulfill a transaction and how much they want to contribute to miners. Any portion not paid to miners is burned.

The primary intention of EIP-1559 was to stabilize gas prices, and Coinbase adopted EIP-1559 into its network fee structure.

For additional details about fee calculation on Base, please refer to their op-stack developer documentation.

How is Optimism different from Ethereum?

As an EVM-compatible chain, the OP Stack is very similar to Ethereum. In fact, the OP stack is built to be as close to Ethereum as possible.

However, as part of its core mechanism, the L1 Data Fee is automatically charged to any transaction included in an OP Mainnet block. That fee is deducted from the address sending the transaction. The amount pulled just depends on the estimated transaction size, the current gas price on Ethereum and/or blob gas price, and a few other factors.

Blocknative is the industry leader in gas estimation APIs, and can help ensure transactors accurately predict gas prices to avoid stuck transactions and other common problems that arise from unpredictable gas.

For more information about how OP Mainnet operates, you can refer to Optimism Docs.

Driving gas solutions with Blocknative

Apps, projects, and protocols within the Optimism ecosystem should consider using Blocknative to drive gas solutions at scale.

You can learn more about our gas estimators and decoding APIs here. And reach out to the Blocknative team on Telegram to schedule a call.

Observe Ethereum

Blocknative's proven & powerful enterprise-grade infrastructure makes it easy for builders and traders to work with mempool data.

Visit ethernow.xyz

Want to keep reading?

Good choice! We have more articles.

blocknative-gas-estimator-extension-now-supports-multiple-blockchains!
Gas

Blocknative Gas Estimator Extension Now Supports Multiple Blockchains!

Big News: Blocknative Gas Estimator Extension Now Supports Multiple Blockchains! We're super..

understanding-blocknative's-gas-estimator:-why-do-some-predictions-show-the-same-values?
Gas

Understanding Blocknative's Gas Estimator: Why Do Some Predictions Show the Same Values?

Understanding Blocknative's Gas Estimator: Why Do Some Predictions Show the Same Values? If you've..

base-101:-how-gas-works-on-base
Gas

Base 101: How Gas Works On Base

Incubated and developed by the popular centralized exchange Coinbase, Base is an Ethereum Layer..

Connect with us. Build with us.

We love to connect with teams who are building with Blocknative. Tell us about your team and what you would like to learn.

"After first building our own infrastructure, we appreciate that mempool management is a difficult, expensive problem to solve at scale. That's why we partner with Blocknative to power the transaction notifications in our next-generation wallet."

Schedule a demo