HomeEnglishEthereum gas fees: a worked example of maximum and actual cost

Ethereum gas fees: a worked example of maximum and actual cost

Cryptofocus bron in google
Bybit - sponsored
Ontvang nu een welkomstbonus bij Bybit, maar liefst 30 USDC!

Consider an Ethereum contract transaction with a maximum network-fee budget of 0.004 ETH. If it uses 50,000 gas at an effective price of 22 gwei, its execution fee is 0.0011 ETH. The gap comes from two separate limits: how much computation the transaction may use and how much the sender permits each unit to cost.

What you need to know
The gas limit caps the units of computation a transaction may consume.
The maximum fee per gas includes the base fee and the priority fee.
The execution charge uses gas actually consumed at the effective gas price.
A transaction must satisfy the maximum-budget balance check before execution.

These figures are a hypothetical example for an ordinary EIP-1559 transaction on Ethereum mainnet, with no ETH transferred to the recipient. They are not a live fee quote. Blob transactions, sponsored transactions and layer-2 networks can involve additional or different fee arrangements.

Two ceilings, one final calculation

Set the gas limit to 100,000 units, the maximum fee to 40 gwei per unit and the maximum priority fee to 2 gwei. Multiplying the first two numbers gives the 0.004 ETH ceiling: 100,000 × 40 × 0.000000001 ETH. One gwei is one billionth of an ETH.

Now assume the inclusion block has a base fee of 20 gwei. The priority fee fits beneath the 40-gwei cap, so the effective price is 20 + 2 = 22 gwei. If execution uses 50,000 units, the charge becomes 50,000 × 22 gwei, or 0.0011 ETH. The sender is not charged 40 gwei for every unit of the 100,000-unit allowance.

Lees ook:  A MetaMask password is not a recovery backup for a phrase-created wallet

The EIP-1559 specification sets out the distinction. It caps the priority fee at the smaller of the chosen tip and the space left after the base fee. It also returns unused gas in its reference accounting. The calculation above applies those rules; it does not describe a later refund that requires contacting a wallet provider.

Why a sufficient final balance can still fail the upfront check

A balance of 0.003 ETH would cover the example’s eventual 0.0011 ETH charge, but it would not cover the 0.004 ETH maximum budget. EIP-1559 checks affordability against the gas limit multiplied by the maximum fee per gas, in addition to any ETH being sent. That comparison explains why an expected fee and an insufficient-funds warning can coexist.

Changing the gas limit is consequential. As MetaMask’s gas-fee explanation describes, setting it too low can make execution fail while still consuming gas. Unused capacity and failed computation are different: work already performed can remain chargeable even when the intended contract action does not complete.

For the completed example, the useful comparison is therefore 50,000 units used against 100,000 allowed, and 22 gwei paid against 40 gwei permitted. Raising a ceiling is permission for a larger possible charge; the final execution charge still depends on the transaction’s measured consumption and its inclusion-block price.

Partnerdeal

Bybit - Welkomstbonus 30 USDC!

Ontvang nu een welkomstbonus bij Bybit, maar liefst 30 USDC!.

Lees hier de voorwaarden
Nu naar Bybit
Voorkeur cryptofocus google nieuws
Lotte Herkens
Lotte Herkens
Lotte Herkens schrijft over crypto alsof het om geld gaat dat je morgen echt nodig hebt. Ze volgt bitcoin en altcoins al jaren, maar wordt pas enthousiast als er data, adoptie of beleid achter zit. Haar stukken zijn kort, scherp en praktisch: wat is er gebeurd, waarom boeit het, en wat kan het betekenen voor je portfolio? Ze heeft een zwak voor on-chain trends, macro-cijfers en alles wat schuurt tussen regelgeving en innovatie. Als ze niet schrijft, zit ze vaak met een koffie in de trein, podcasts te luisteren, of maakt ze lange wandelingen om een verhaal “recht” te krijgen. Lotte is nuchter, nieuwsgierig en allergisch voor hype. Ze wil dat lezers snappen wat er speelt — zonder dat het voelt alsof je een whitepaper moet doorploegen.
Lees ook