Gas, Transactions and Failed Attempts
Section 1 of 4
Transaction stages and gas pricing
Your learning goal
Read an Ethereum-style transaction and estimate the fee with clearly stated inputs.
Gas measures the work required to execute a transaction on Ethereum. It is not a second token you must buy separately: fees are paid in the relevant native fee asset under the network's rules. We will separate units of work from price per unit, calculate a fee and explain why a failed contract action can still cost money.
Key idea
Read the receipt and calculate fees with units at every step.
Education only. Crypto assets can lose substantial value or become worthless. No lesson requires buying an asset, depositing money or sharing real passwords, private keys or recovery words.
The transaction lifecycle and account nonce
An Ethereum transaction includes information such as sender authorisation, destination, value, data and fee settings. An account nonce orders its transactions and prevents ordinary replay of the same account instruction. Signing prepares authorisation, broadcasting shares the transaction, inclusion executes it in a block, and the receipt records its result. These are separate stages.
A pending transaction can affect later transactions from the same account. Wallets may offer replacement or cancellation-style actions using the same nonce, but support and outcome depend on current rules and whether inclusion has occurred. A confirmed action cannot simply be recalled through a local button. When an interface appears stuck, inspect the correct network's transaction record and nonce context rather than submitting repeated actions without diagnosis.
Gas used gas limit and effective price
Ask why every action on Ethereum has a price
Think about a taxi meter. It doesn't care who you are. It counts distance and waiting time, and the longer the trip, the more you pay.
Ethereum works in a similar way. In the Ethereum and contract lessons in Level 4 you saw that every node runs every smart-contract step through the EVM. Each step takes computing effort, measured in units called gas. A plain ETH transfer is a short trip; a contract action that touches several contracts is a long one. ethereum.org explains that charging for every computation also stops attackers flooding the network with junk code.
Gas units tell you how much work a transaction needs. They don't tell you the price of each unit. That price is quoted in a tiny slice of ether called gwei.
The taxi analogy stops working in one place. On Ethereum, the price of each gas unit also rises and falls with how many people want space in the next block, more like surge pricing at rush hour. The rules for that price changed in 2021.
Split the fee base fee tip and the burn
In August 2021 the London upgrade brought in a change called EIP-1559. Since then, the price of each unit of gas has two parts. The base fee is set by the protocol for each block, and every transaction in that block pays it. The optional priority fee, or tip, is extra you add to encourage validators to include your transaction.
Picture a toll road with a congestion charge that rises when traffic is heavy and falls when it is light. Ethereum's base fee behaves like that. Each block has a target size of half its maximum. If a block is fuller than the target, the next base fee rises, by up to 12.5%; if emptier, it falls.
Here is the unusual part. When the block is created, the base fee is burned: removed from circulation for good. Only the tip goes to the validator. The toll analogy breaks down here, because a city keeps its congestion charge.
Your wallet usually also sets a max fee, the most you will pay per unit of gas. If base fee plus tip comes in lower, the difference is refunded. If the base fee climbs above your max fee, your transaction waits.
| Part | Who sets it | Where the money goes |
|---|---|---|
| Base fee | The protocol, block by block, based on demand | Burned (destroyed) |
| Priority fee (tip) | You, usually from your wallet's suggestion | The validator who includes your transaction |
| Max fee | You, as a ceiling | Not a payment; any unused amount is refunded |
You may read that the burn makes ETH "scarcer" and must push its price up. Burning changes how much ether is in circulation; it does not decide what anyone will pay for ETH. Treat any claim that a fee rule will raise the price as marketing, not fact.
With the parts named, you can now put numbers to them.
Gas units measure computational work under protocol rules. The effective price per gas combines applicable fee components under current rules. A wallet's maximum fee setting is a cap, not necessarily the amount charged for every gas unit. More complex network routes may include other fees, so the simple formula must be labelled with its scope. Unused permitted gas is not generally charged as though it were all consumed. However, a transaction can consume gas up to its limit and fail, which is different from merely setting a generous limit.
Section 2 of 4
Calculate the fee with units
One gwei is one-billionth of an ETH. If an illustrative transaction uses 21,000 gas at an effective price of 20 gwei per gas, it costs 420,000 gwei. Dividing by one billion gives 0.00042 ETH. At a fictional USD 2,000 per ETH, that is USD 0.84. Neither fee input nor ETH price is a live recommendation.
A basic transfer and a contract action can consume different gas amounts. Sending ETH to a contract can also trigger additional work, so 21,000 is not a universal value for every transfer-looking operation. If a hypothetical contract action uses 80,000 gas at 20 gwei, its fee is 0.0016 ETH. Always keep gas units, gwei per gas, ETH and currency valuation distinct in your worksheet.
| Step | Calculation | Result |
|---|---|---|
| Gas consumed | Supplied example | 21,000 gas |
| Effective price | Supplied example | 20 gwei per gas |
| Fee in gwei | 21,000 × 20 | 420,000 gwei |
| Fee in ETH | 420,000 ÷ 1,000,000,000 | 0.00042 ETH |
| USD illustration | 0.00042 × 2,000 | USD 0.84 |
Simplified Ethereum execution fee only. Other network or service charges are excluded.

Read diagram as text
21,000 gas × 20 gwei per gas = 420,000 gwei.
420,000 gwei = 0.00042 ETH. At the fictional USD 2,000 per ETH, this is USD 0.84.
This is a simplified execution-fee example, not a live quote or a full cost estimate for every network.
Section 3 of 4
Failed actions, receipts and retries
Why a failed action can still cost gas
A mechanic who spends two hours searching for a fault still charges for the two hours, even if they cannot fix it. The work was done.
Ethereum treats failure the same way. If a transaction runs out of gas, or a contract's rules reject it partway, every change it tried to make is undone and your tokens stay where they were. But the gas already used is not returned, because the nodes really did the computing.
If your wallet warns that a transaction is likely to fail, stop and check. That is cheaper than paying for a failure.
Gas explains what you pay for execution. The receipt explains which actions actually happened.
A transaction may be included and then revert because a condition fails. A pre-broadcast rejection is a different stage and may not create an on-chain fee. Check receipt status rather than inferring success from a transaction ID alone. A failed swap may leave the original asset in the wallet while still reducing the native fee balance. A separate approval might have succeeded before the swap failed, leaving permission to review. The overall task's failure does not mean every earlier step was cancelled.
Read the receipt before trying again
Verify the account, network, transaction ID, pending status, nonce and receipt. Determine whether the fee asset is sufficient and whether the intended action failed for a stated reason. Avoid using a lookalike explorer linked by an unsolicited helper. If the account may be compromised, return to the incident-response guidance before adding fee funds.
Layer-two networks can have their own fee components and native fee rules. Do not apply a mainnet illustration as a complete quote for every chain. Record the network and fee estimate at the time of the example, then compare the actual receipt afterward. This makes a gas lesson useful beyond memorising a formula: it connects cost, status and permission to the action you intended.
Section 4 of 4
Everyday example, practice and review
Try the following questions aloud or on paper before opening the worked answers. Compare your reasoning as well as your final answer.
Try it yourself
Try each question on paper or explain your answer aloud before opening the worked answers. This practice is for learning; it is not scored.
1. Calculate the fee for 80,000 gas at 25 gwei and value it at fictional USD 2,000 per ETH.
2. An approval succeeds and a later swap reverts. Is the approval necessarily removed?
3. What distinguishes a receipt marked failed from an action never broadcast?
Compare with the worked answers
Worked answers
1. 80,000 × 25 = 2,000,000 gwei = 0.002 ETH, worth USD 4 at the supplied price.
2. No. The approval is a separate action and may remain. Review it using verified permission guidance.
3. The included failed transaction may have consumed gas. An action rejected before broadcast is not the same on-chain execution event.
Quick knowledge check
Try each question on paper or explain your answer aloud before opening the worked answers. This practice is for learning; it is not scored.
Is gas limit multiplied by the maximum fee always the actual final charge?
Compare with the worked answers
Worked answers
No. Actual charges depend on gas consumed and effective fee components under the specific network rules.
What to remember
✓ Gas units and fee price are different inputs.
✓ A transaction ID alone does not prove success.
✓ A failed step can leave earlier permissions and costs intact.
Lesson completion check
References and further reading
References
Ethereum: Ethereum security and scam prevention ↗
ethereum.org: ethereum.org — Gas and fees ↗
ethereum.org: ethereum.org — ERC-20 token standard ↗
ethereum.org: ethereum.org — ERC-721 non-fungible token standard ↗