EconoFlux
BTC / USD $78,354.00 +0.57% 24h ETH / USD $2,290.58 +0.90% 24h SOL / USD $94.78 -1.10% 24h
Crypto Prices (Beta) · Up to 15 min delayed. Updated:

Ethereum & smart contracts / 9 min read

Ethereum gas fees explained: how costs, limits and tips work

A beginner's guide to Ethereum L1 gas: what gas units mean, how EIP-1559 splits base fee and priority fee, gas limits vs gas used, failure and refund rules, practical examples and wallet tips.

Educational guide · Sources checked before publication · AI-assisted

Original educational diagram: Ethereum gas fees explained: how costs, limits and tips work
Original EconoFlux educational illustration; conceptual diagram, not a photograph.

What gas means on Ethereum

Gas is the accounting unit Ethereum uses to measure the computational work required to execute transactions and smart contract operations. Every operation executed by the Ethereum Virtual Machine (EVM) consumes a fixed number of gas units determined by the protocol.

Fees paid by a transaction sender are the product of the gas used and the per‑unit gas price, and those fees are paid in ETH. Ethereum.org describes gas as the link between resource consumption on the network and the ETH that pays for it.

Denominations: wei, gwei and ETH

Ethereum's native currency is ETH, and the smallest unit is wei. One gwei equals 1,000,000,000 wei (10^9 wei). Wallets and tools commonly quote gas prices in gwei because it is a convenient scale between wei and ETH.

When you see a suggested gas price like '20 gwei' that means 20 × 10^9 wei per gas unit. Multiplying gas units by that per‑unit price yields the ETH cost for the transaction.

EIP‑1559: base fee, priority fee and max fee

H3: EIP‑1559 in plain English / EIP‑1559 explicado en palabras sencillas

EIP‑1559 changed how per‑transaction fees are expressed and processed. The protocol now defines a per‑block base fee that is algorithmically adjusted and burned (removed from supply). Transactions also include a priority fee (often called a tip) that goes to the block proposer (validator).

A sender supplies two fields for modern EIP‑1559 transactions: maxPriorityFeePerGas (the tip) and maxFeePerGas (the maximum the sender is willing to pay per gas unit). The effective gas price the sender pays is the base fee plus the priority fee, but the sender never pays more than maxFeePerGas; any unused portion is refunded.

Ethereum.org and EIP‑1559 documentation clarify these roles: base fee stabilizes fee expectations and is burned, while the priority fee motivates validators to include a transaction.

How the base fee changes block to block

The base fee is adjusted each block based on how full the parent block was relative to the target. If the parent used more gas than the target, the base fee increases; if it used less, the base fee decreases.

The protocol caps per‑block base fee change to ±12.5% relative to the previous base fee. Ethereum.org explains that blocks also have an effective target and an elasticity multiplier: the gas limit that a block can consume is allowed to vary so short bursts of demand can be accommodated, but repeated full blocks cause the base fee to rise.

Gas limit vs gas used: what to set and what happens

Every transaction includes a gas limit: the maximum gas the sender allows the transaction to consume. Gas used is the actual amount consumed during execution. If the transaction consumes less than the gas limit, the unused gas is refunded to the sender (the refund is implemented in ETH according to the effective gas price behavior).

If a transaction runs out of gas during execution (it hits the gas limit before finishing), the EVM reverts state changes made during that call, but the gas used until the point of failure is still burned and not refunded. Ethereum.org explicitly states that failed transactions still consume gas for the work done.

Intrinsic costs and the 21,000 gas for a simple ETH transfer

A simple peer‑to‑peer ETH transfer on L1 has an intrinsic gas cost of 21,000 gas units. This is the protocol's standard minimum for a basic transfer; it applies only to that transaction type.

Complex operations—contract calls, token transfers, or interactions that execute many opcodes—consume additional gas according to each operation's fixed gas cost, so the gas used can be far higher than 21,000 for contract interactions.

Legacy transactions and maxFeePerGas behavior

Legacy (pre‑EIP‑1559) transactions specify a single gas_price field. Under the post‑1559 rules these transactions remain valid: their gas_price is interpreted as both the max fee and the priority fee when normalized to the new model.

EIP‑1559 transaction types (type 0x02) explicitly separate maxPriorityFeePerGas and maxFeePerGas. The protocol ensures the sender never pays more than the declared maxFeePerGas and refunds any excess after the block's base fee and priority fee are accounted for.

Failed transactions, out‑of‑gas and refunds

If a transaction fails because it reverts or runs out of gas, the state reverts to the pre‑transaction state, but gas used up to the failure point is still consumed and paid by the sender. That gas pays for the execution effort and is not refunded.

Conversely, if the transaction completes successfully and its gas limit exceeded the gas used, the unused portion is returned to the sender. Wallets typically show an estimated gas limit; they may also show the estimated gas cost based on current base fee and a recommended priority fee.

How wallets and tools estimate fees

Wallets commonly auto‑estimate the base fee plus a recommended priority fee so users rarely need to calculate fees manually. These estimates derive from recent block data: recent base fees, recent priority fee levels, and gas used patterns.

Ethereum.org lists third‑party monitoring tools (such as block explorers and gas trackers) as helpful for users who want live perspectives on base fee and common priority fee levels; these are third‑party resources referenced by ethereum.org, not protocol functions.

Clear hypothetical example (labelled hypothetical)

Hypothetical calculation: assume a simple ETH transfer that uses exactly 21,000 gas units. If the block base fee is 50 gwei and the sender set a priority fee of 2 gwei and maxFeePerGas of 60 gwei, the effective gas price the sender pays is base fee + priority fee = 52 gwei, provided that is less than or equal to the maxFeePerGas. Total cost in gwei = 21,000 × 52 = 1,092,000 gwei. To convert to ETH you would divide gwei by 10^9: 1,092,000 gwei = 0.001092 ETH.

This number is a hypothetical illustrative calculation and not a live price estimate. It shows how gas units, base fee and priority fee combine to produce the paid fee and how the maxFeePerGas caps the amount charged.

Comparison of fee elements and behaviors

The table compares primary fee elements and legacy behavior to help you understand differences and limits.

ElementPrimary roleWho receives itAdjustability / where setNotes
Base feeProtocol-level fee to stabilize demandBurned (removed from supply)Algorithmically adjusted each block (±12.5% cap)Determined by block usage relative to target; not set by user
Priority fee (tip)Incentive for validator to include txBlock proposer (validator)Set by transaction sender (maxPriorityFeePerGas)Added to base fee to form effective gas price
Max fee (maxFeePerGas)Sender's cap on how much per gas they will payExcess refunded to sender; paid amount goes partly to burn (base fee) and partly to validator (priority fee)Set by transaction senderProtects sender from spikes; unused portion refunded
Gas limit (per tx)Maximum gas units allowed for the executionN/A (controls execution resource consumption)Set by sender (wallet may suggest)If execution uses less gas, unused gas is refunded; if it runs out the state reverts but gas is consumed
Legacy gas_priceSingle price used pre‑EIP‑1559Interpreted as both max fee and priority fee after normalizationSet by senderLegacy transactions remain valid but behave like a single‑field max/priority

Advantages, limitations and risks to be aware of

Advantages of EIP‑1559 include clearer fee estimation (base fee gives a predictable component and burning reduces miner reward volatility) and automatic refunds of over‑paid max fees. Wallets can use recent base fee history to produce better user recommendations.

Limitations and risks include: the base fee can change rapidly if block demand changes, so a maxFeePerGas that is too low can prevent inclusion; failed transactions still consume gas and therefore cost ETH; complex contract interactions require correct gas limit estimation to avoid running out of gas; and third‑party trackers provide guidance but are not protocol guarantees.

Block gas capacity and base fee are protocol-driven; validators cannot bypass the base fee burn. Short‑term block elasticity exists but repeated high usage raises the base fee.

Tools and monitoring best practices

Use your wallet's suggested fees for routine transactions unless you need a custom behavior. If you are preparing complex contract interactions, review the wallet's estimated gas limit and consider using a development tool to estimate gas consumption beforehand.

Consult reputable block explorers and gas trackers to see recent base fee trends and typical priority fees. Ethereum.org lists such third‑party resources to help users understand current conditions.

FAQ

Q: Will I lose ETH if a transaction fails? A: You will lose the ETH paid for gas that was consumed up to the failure point; the state changes revert but gas used is not refunded.

Q: Is 21,000 gas always the cost to send ETH? A: No. 21,000 gas is the intrinsic cost for a simple L1 ETH transfer. More complex value transfers or contract interactions consume additional gas.

Q: What happens if my maxFeePerGas is lower than the base fee when the tx reaches the network? A: The transaction will not be included until the base fee decreases or the sender increases the maxFeePerGas. Wallets often check current base fee and recommend appropriate maxFeePerGas values.

Q: Can I set zero priority fee? A: You can set a low or zero priority fee, but validators are less likely to include such transactions when there is competition for block space. The base fee is still burned and must be covered by the sender up to their maxFeePerGas.

Q: Do wallets always overcharge me? A: Wallets typically recommend conservative max fees and may round up to ensure inclusion; they also refund any unused portion. Review the detailed transaction parameters in your wallet before confirming if you want finer control.

Conclusion: practical takeaways

Gas is the unit of compute on Ethereum; fees equal gas used times the effective gas price. EIP‑1559 separates a burned base fee from a priority fee to validators and uses a max fee cap to protect senders. Wallets and tools provide estimates based on recent block behavior so most users can rely on recommendations for routine transfers.

To act safely: confirm wallet estimates before sending, set a sensible gas limit (use the wallet's recommendation for contract interactions), understand that failed transactions still consume gas, and use reputable explorers or trackers if you need more visibility into base fee and priority fee levels.

Sources & further reading

Sources and methodology · Report a correction

For information only. Not financial advice.

Read in Spanish →