Ethereum gas fees are not random. Here is how they work.

Ethereum gas fees are not random. Here is how they work.

Gas fees are not random. They are the cost of computation on Ethereum. Here is how they work, what affects the price, and how to keep costs down.

February 16th, 2026 · Build

If you are building a product on Ethereum, gas fees are one of the first things your users will complain about. They are also one of the first things your engineering team will need to optimize around. Understanding gas does not require a computer science degree. It requires about five minutes.

What are gas fees, in plain English

Think of Ethereum as a global computer that thousands of people share. Every operation you ask it to perform, storing a number, checking a condition, sending tokens, takes computational effort. Gas is how Ethereum measures and prices that effort.

The analogy that works best: gas fees are the electricity bill for running code on the blockchain. A simple operation (flipping a light switch) costs almost nothing. A complex operation (running an industrial machine) costs more. You pay for exactly what you use, and the price per unit fluctuates based on how busy the network is.

Gas is denominated in gwei, a tiny fraction of ETH. One gwei equals 0.000000001 ETH (one billionth). When someone says “gas is at 3 gwei,” they mean the current price per unit of computational work is 3 billionths of an ETH.

Why this matters for your project

Gas affects three things founders care about: cost, user experience, and architecture.

Cost. Every transaction your users make has a gas fee attached. If your contract is poorly optimized, a single interaction could cost dollars instead of cents. Multiply that by thousands of users and the difference is significant.

User experience. Users see gas fees before they confirm a transaction. A high fee estimate can cause them to abandon the action entirely. This is especially true for consumer-facing products where your users are not crypto-native.

Architecture decisions. Gas costs should influence which chain you deploy on, how your contracts store data, and whether you use Layer 2 networks. On Ethereum mainnet in early 2026, a simple ETH transfer costs a few cents. On Layer 2 networks like Arbitrum, Base, or Optimism, that same transfer costs a fraction of a cent.

The Dencun upgrade in 2024 reduced Layer 2 fees by over 90% through blob transactions. The Pectra upgrade in May 2025 further reduced costs by doubling blob capacity. Together, these upgrades have made Layer 2 networks viable for nearly every use case.

How it works (the 30-second version)

Since EIP-1559 (August 2021), Ethereum uses a two-part fee structure:

  • Base fee: Set automatically by the network based on demand. This gets burned (permanently removed from circulation). It adjusts up or down by a maximum of 12.5% per block.
  • Priority fee (tip): An optional amount you add to incentivize validators to include your transaction faster.

The formula is simple:

Total fee = gas units used x (base fee + priority fee)

A standard ETH transfer uses exactly 21,000 gas units. If the base fee is 3 gwei and you add a 1 gwei tip, the math looks like this:

21,000 x (3 + 1) = 84,000 gwei = 0.000084 ETH

At an ETH price of $2,500, that is about $0.21. Your wallet handles all of this automatically. You set a maximum you are willing to pay, and any unused portion gets refunded.

Different operations cost different amounts of gas because they require different levels of computational effort:

OperationGas unitsWhy
ETH transfer21,000Minimal computation
ERC-20 token transfer~65,000Updates storage mappings
Writing to storage (new value)22,100Most expensive: permanent state change
Reading from storage2,100Cheaper, but still not free
Emitting an event log~375 + dataLogs are cheap, not stored in state
Simple arithmetic3-5Trivial computation

The pattern is clear: storage is expensive, computation is cheap, and logs are somewhere in between.

How Doodledapp makes this visual

When you build a contract in Doodledapp, every node on your canvas represents an operation that costs gas. This means you can literally see where your costs come from.

State Variable nodes represent storage operations, the most expensive category. Each one writes data permanently to the blockchain. When you see a flow graph covered in State Variable nodes, you are looking at an expensive contract. This visual signal helps you ask the right question early: does this data really need to live on-chain?

Require nodes add validation checks and they are cheap. Better yet, they save gas by reverting the transaction early when a condition fails. Every Require node at the top of a function is a guardrail that prevents users from wasting gas on operations that would fail anyway.

Event and Emit Event nodes use log storage instead of state storage. They cost a fraction of what a state write costs. If you only need external systems (like a frontend) to read certain data, events are the right choice.

Loop nodes multiply gas costs by the number of iterations. A loop over 10 items costs 10x. A loop over 1,000 items might exceed the block gas limit entirely and fail. When you see a Loop node in your flow, it should trigger an immediate question: how large can this dataset grow?

By building visually, you develop an intuition for contract complexity before you ever deploy. A flow graph with a clean, linear path through a few nodes will be cheap to execute. A graph with nested loops, heavy storage writes, and branching conditions will be expensive. You can see this at a glance.

Common mistakes to avoid

Storing data on-chain that belongs off-chain. Not everything needs to live in a smart contract. User profile metadata, images, or large text blobs should go in IPFS or a database. Store only the hash or reference on-chain. Every 32-byte storage slot costs over 20,000 gas to write for the first time.

Unbounded loops. If your contract iterates over an array that grows with user activity, you are building a ticking time bomb. Eventually the loop will consume more gas than a single block allows, and the function becomes permanently uncallable. Use mappings for lookups instead of looping through arrays.

Skipping early validation. Put your require checks at the top of every function. If a transaction is going to fail, it should fail immediately. Every operation executed before the revert still costs gas that the user does not get back.

Ignoring Layer 2 options. Unless you specifically need Ethereum mainnet’s security guarantees for every transaction, Layer 2 networks offer the same Solidity compatibility at 90-99% lower cost. Arbitrum, Base, and Optimism all execute standard Solidity contracts.

The bottom line

Gas fees are not a tax. They are a direct reflection of what your contract asks the network to do. Understanding the cost of each operation, storage writes, computation, event logs, gives you the knowledge to design contracts that are efficient by default. The less gas your users burn, the better their experience, and the more viable your product becomes at scale.

Spot an inaccuracy or a bug?