Blockchain AcademicsBlockchain Academics
Ethereum & Smart Contractsintermediate

Understanding Gas Fees

Every transaction on Ethereum costs something beyond the ETH you are actually sending or the token you are swapping. That extra cost is gas, and misunderstanding it is one of the most reliable ways to lose money on small transactions, get stuck waiting hours for a confirmation, o

By Alejandro Silva Ramírez · Updated September 22, 2026
Understanding Gas Fees cover

Understanding Gas Fees

Every transaction on Ethereum costs something beyond the ETH you are actually sending or the token you are swapping. That extra cost is gas, and misunderstanding it is one of the most reliable ways to lose money on small transactions, get stuck waiting hours for a confirmation, or accidentally overpay by a significant margin.

Gas is not a fee that goes to Ethereum's founders or any central authority. It is the unit of computational work required to execute an operation on the Ethereum network. Think of it like the fuel in a car: the engine does not care where you are going, it cares how far and how hard it has to work. A simple ETH transfer is a short trip on flat road. A complex interaction with a decentralized exchange or a lending protocol is a mountain crossing.

Understanding how gas is priced, why it fluctuates, and how to work with it rather than against it will save you real money and frustration over time.

What Gas Actually Measures

Every operation the Ethereum Virtual Machine (EVM) executes has a fixed gas cost assigned to it. The EVM is the computational engine that runs smart contracts, which are self-executing programs stored on the blockchain. Simple operations like adding two numbers cost 3 gas. Reading from storage costs 200. Writing to storage costs thousands. These costs are defined in Ethereum's protocol and do not change with market conditions.

A standard ETH transfer always costs exactly 21,000 gas units because the set of EVM operations it requires never changes. A token swap on a decentralized exchange might cost 150,000 to 250,000 gas units because the smart contract does far more work: it checks balances, calculates prices, updates reserves, transfers tokens, and emits event logs.

The gas limit is the maximum amount of gas you authorize for a transaction. If your transaction completes using less than the limit, you get the remainder refunded. If execution would require more gas than you authorized, the transaction fails, and you still pay for the work that was done up to that point. This is why setting the gas limit too low is a costly mistake.

How the Gas Price Is Set: EIP-1559

Before EIP-1559, users set a single gas price and miners chose which transactions to include based on who paid most. This created chaotic bidding wars during busy periods and made fee estimation almost impossible.

EIP-1559, activated in the London upgrade, restructured this entirely. The system now has two components.

The base fee is a protocol-determined price per gas unit that applies to every transaction in a given block. It rises when blocks are more than 50% full and falls when blocks are less than 50% full. The base fee is burned, meaning it is permanently removed from circulation and goes to no one. Your total ETH cost from the base fee is simply: base fee multiplied by gas units used.

The priority fee, sometimes called the tip, goes directly to the validator who includes your transaction. This is how you signal urgency. When the network is quiet, a priority fee of 1 gwei (one billionth of an ETH) is usually enough. During a popular NFT mint or a period of market volatility, validators will naturally sort transactions by tip, so a higher priority fee means faster inclusion.

You also set a max fee, which is the absolute ceiling you are willing to pay per gas unit. The actual amount you pay is always: actual base fee plus priority fee, per gas unit used, and never more than your max fee. If the base fee drops while your transaction is pending, you benefit automatically.

A concrete example: suppose the base fee is 20 gwei, you set a max fee of 30 gwei and a priority tip of 2 gwei. Your transaction gets included, the base fee at that moment is 19 gwei, and you pay 21 gwei per unit (19 base plus 2 tip). You pay less than your maximum, and the validator earns the 2 gwei tip.

Reading a Gas Estimate in Practice

Most wallets display gas estimates in ETH or your local currency before you confirm. What they are calculating is:

Estimated cost = gas units used x (base fee + priority tip)

When a wallet shows you "slow," "average," and "fast" options, it is adjusting the priority fee. The base fee is the same for all three because it is set by the protocol. The distinction is only how much you are tipping to move ahead of other pending transactions.

Some wallets also show the gas limit separately from the gas price. Reducing the gas limit dramatically to try to save money is not advisable: the savings are tiny and the risk of a failed transaction that still consumes gas is real.

Strategies to Reduce What You Pay

The base fee follows network congestion, so the most reliable way to pay less is to transact when demand is lower. Ethereum activity tends to be highest during peak hours in North American and European time zones on weekdays. Early morning UTC hours and weekends often see meaningfully lower base fees. Gas tracker dashboards, many of which are built into wallets, let you watch the base fee trend before submitting.

Batching transactions reduces total gas spent. If you are interacting with a protocol that requires you to first approve a token and then execute a swap, some interfaces let you do this in a single transaction rather than two. Not all protocols support this, but it is worth checking.

Priority fee discipline matters during normal conditions. Setting a modest tip of 1 to 2 gwei is usually sufficient when the network is not congested. Overpaying on tips during quiet periods is pure waste.

Layer 2 networks offer the most dramatic reduction available. Networks like Arbitrum and Optimism execute transactions off the Ethereum mainnet and post compressed proofs back to it. Gas costs on these networks are typically a fraction of mainnet costs for the same operations. If you are doing regular swaps or other high-frequency activity, moving to a Layer 2 is worth understanding thoroughly. The BCA Academy covers Layer 2 mechanics in dedicated courses for a full grounding on the subject.

Risks and Common Mistakes

Setting the max fee too close to the base fee means your transaction can get stuck if the base fee rises even slightly while it is pending. A transaction sitting in the mempool, which is the waiting area for unconfirmed transactions, can remain there for hours or days before it is either included or dropped.

Canceling a stuck transaction incorrectly is a common source of lost funds. To cancel a pending transaction, you submit a new transaction with the same nonce (a sequential number that tracks your transaction order) and a higher tip. Some wallets handle this automatically. Sending a second transaction to a different address while the first is pending does not cancel the first.

Gas token scams have appeared in various forms. Some contracts claim to refund gas or optimize costs in ways that sound too good to be true. Any protocol whose primary pitch is saving you gas through an opaque mechanism deserves close scrutiny.

Failed transactions still cost gas. If your swap fails because slippage exceeded your tolerance, or because you set the gas limit too low, you have paid for the failed computation and received nothing. This is not a wallet bug; it is how the EVM works.

Frequently Asked Questions

Why did my transaction fail and I still lost money?

When a transaction fails partway through execution, all the state changes are reversed, but the gas consumed up to the failure point is not refunded. Validators still did computational work. The most common causes are a gas limit set too low, or a swap that failed a condition check inside the contract.

What is gwei?

Gwei is a denomination of ETH equal to one billionth of one ETH (0.000000001 ETH). Gas prices are expressed in gwei because the numbers are more readable that way. Saying a base fee is 15 gwei is cleaner than saying 0.000000015 ETH.

Does paying more gas make my transaction more secure?

No. Gas fees affect only how quickly a transaction is included in a block and how prioritized it is among pending transactions. Once a transaction is confirmed, its security is the same regardless of what fee was paid.

Can I get a refund if I overpay?

Under EIP-1559, your max fee acts as a ceiling and you are automatically charged only the actual base fee plus your tip. You will not be charged your full max fee if the actual base fee is lower. The priority tip you set is paid in full to the validator, and there is no partial refund on the tip.