UNDERSTAND BEFORE USING
Gas fees: calculation, gwei and failed transactions
After this lesson: Distinguish the amount of work, its price and the transferred amount.
01 / BEGINNER
First, what is it?
On Ethereum, gas measures the resources needed to execute an operation. It is not a currency. Its price is paid in ETH and often expressed in gwei, a very small ETH unit. Fees pay for network use, not the euro size of your wallet.
Words to know
- Gas used
- The quantity actually consumed during execution.
- Gwei
- One billionth of an ETH: 1 gwei = 0.000000001 ETH.
- Gas limit
- The maximum gas the transaction permits consuming.
The idea to understand
Execution fees equal gas used multiplied by its effective price. Two very different transfer amounts can therefore incur similar fees if the work and gas price are comparable.
SEE IT IN PRACTICE
Now, a concrete example
Fictional simple-transfer calculation: 21,000 gas × 20 gwei = 420,000 gwei = 0.00042 ETH. This fee is additional to the ETH sent. The 20 gwei price is chosen for learning, not a live quote.
YOUR TURN
Does a 60,000 gas limit mean all 60,000 will necessarily be consumed?
Form an answer before opening the explanation. You can also discuss it aloud.
Compare with the explanation
No. The limit is a ceiling. Fees depend on work actually charged. An insufficient limit can cause execution to fail; raising it is different from raising the gas price.
02 / INTERMEDIATE
How it works, and why
Execution fees equal gas used multiplied by its effective price. Two very different transfer amounts can therefore incur similar fees if the work and gas price are comparable.
A complex interaction generally consumes more resources than a simple transfer. Demand for block space also changes the price. A pre-send estimate is not a final bill.
Two people send the same amount of ETH but pay different fees. The amount transferred is not the only factor: the operation performed and the resource price at inclusion also matter.
Gas is not a currency
Gas counts execution resources. Gwei expresses an ETH price: 1 gwei equals 0.000000001 ETH. Distinguish a quantity of gas from a price per unit.
A simple operation uses fewer resources than a complex contract swap. These concepts concern Ethereum and networks using a comparable model; Bitcoin fees are calculated differently.
A calculation using hypothetical numbers
Suppose an operation uses 21,000 units at an effective price of 10 gwei per unit. The fee is 21,000 × 10 = 210,000 gwei, or 0.00021 ETH.
These numbers illustrate the calculation, not a current quote. A more complex operation, programmable account or different network may consume a different amount. Converting to euros also requires the ETH exchange rate at the relevant time.
Price, tip and limit are different
For an EIP-1559 Ethereum transaction, the effective price combines the block’s base fee and a priority fee, within the accepted maximum. The base fee is burned; the priority fee goes to the block proposer.
The gas limit bounds the amount of gas allowed. The maximum price per unit is not necessarily the amount actually paid. A wallet shows an estimate; the transaction receipt records gas used and the effective price.
Why pay for a failed operation?
A transaction included and then reverted during execution has already used resources. State changes can be reversed while fees for work performed remain payable.
A request rejected in the wallet or before inclusion is a different case. Check the status on the correct explorer, not only the interface’s message.
Compare total cost
A swap can add protocol fees and incur slippage. A platform withdrawal can add provider charges. A layer 2 can charge for execution and for publishing data to Ethereum.
- Read the total amount and minimum received before signing.
- Separate network fees from service charges and spread.
- Keep the required fee asset on the network used, unless a third party explicitly covers fees.
- Do not switch networks solely on a quoted price: examine risks, bridges and the cost of returning.
03 / ADVANCED
The rules behind the interface
For an EIP-1559 transaction, the effective price accounts for the base fee and priority fee within maxFeePerGas. The full cap is not necessarily paid. The base fee is burned; the tip goes to the block’s designated recipient.
Distinguish execution gas from other possible components, particularly data fees on layer 2 networks. The simple ETH-transfer formula does not by itself describe every transaction on every network.
YOUR TURN
Base fee 10 gwei, maximum priority 2, total cap 20. What is the effective gas price in this model?
Form an answer before opening the explanation. You can also discuss it aloud.
Compare with the explanation
12 gwei: min(20, 10 + 2). The cap of 20 is not automatically spent. Multiply by gas used to obtain the total.
Use the official sources at the end of this page to inspect these mechanisms further.
A useful companion: Ethereum explained: ETH, contracts and gas
THE SHORT ANSWER
On Ethereum, execution fees equal gas used multiplied by the effective gas price. Gas is a quantity of resources; gwei is a small unit of ETH used to express its price. Cost depends on the operation and network conditions.
Sources and further reading
- Ethereum.org — Gas and fees · in English
- EIP-1559 — Fee market · in English
- Ethereum.org — Transactions · in English
- Ethereum.org — Optimistic rollups · in English
Page updated on
Documentation checked on · WhyTheBlockchain · Editorial approach