Skip to content

Gas

Gas is Ethereum’s metering system. It prevents infinite computation and helps protect the network from denial-of-service behavior.

Terminal window
# cast should be installed
$ cast gas-price --rpc-url https://ethereum-sepolia-rpc.publicnode.com
4845187414

Part 1: Fee Formula (Execution-Layer Accurate)

Section titled “Part 1: Fee Formula (Execution-Layer Accurate)”

Note:

  • Affordability check uses gasLimit * maxFeePerGas.
  • Final fee charged uses gasUsed * effectiveGasPrice.
Gas System FieldWhat It RepresentsRole in the Fee System
gasLimitMaximum execution gas the sender authorizesPrevents unbounded computation and caps gas exposure
gasUsedActual execution gas consumed by the transactionFinal fee is charged on this value, not gasLimit
gasPriceLegacy flat fee per gas unitUsed by pre-EIP-1559 (type-0) transactions
baseFeeNetwork-set base gas price per blockBurned under EIP-1559 and adjusts with demand
maxPriorityFeePerGasSender-set maximum tip per gas for proposerIncentivizes faster inclusion
maxFeePerGasSender-set maximum total fee per gasCaps worst-case effective gas price
maxFeePerBlobGasSender-set max blob fee per blob gas (type-3)Caps blob-fee exposure for EIP-4844 transactions
blobBaseFeeProtocol-set blob base fee (type-3 market)Burned for blob data under EIP-4844

For type-2 (EIP-1559) transactions, total execution fee paid is:

TotalFeePaid=gasUsed×effectiveGasPriceTotalFeePaid = gasUsed \times effectiveGasPrice

Practical cap rule:

effectiveGasPrice=min(maxFeePerGas, baseFee+maxPriorityFeePerGas)effectiveGasPrice = \min(maxFeePerGas,\ baseFee + maxPriorityFeePerGas)

Where:

  • baseFee is protocol-set and burned.
  • effectivePriorityFee is the validator tip actually paid.
  • If baseFee + maxPriorityFeePerGas > maxFeePerGas, the effective priority fee is reduced.
  • Equivalently:
effectivePriorityFee=max(0, min(maxPriorityFeePerGas, maxFeePerGasbaseFee))effectivePriorityFee = \max\left(0,\ \min\left(maxPriorityFeePerGas,\ maxFeePerGas - baseFee\right)\right)
  • If baseFee > maxFeePerGas, the transaction is not includable in that block.

For type-3 (EIP-4844) transactions, total fee has two components:

TotalFeePaid=gasUsed×effectiveGasPrice+blobGasUsed×blobBaseFeeTotalFeePaid = gasUsed \times effectiveGasPrice + blobGasUsed \times blobBaseFee

With includability constraints:

  • baseFee <= maxFeePerGas
  • blobBaseFee <= maxFeePerBlobGas

Note: receipt effectiveGasPrice refers to execution gas pricing, not blob-fee pricing.

ETH transfer gas used is typically 21,000.

If:

  • baseFee = 10 gwei
  • priority fee = 2 gwei

Then:

Fee=21000×(10+2)=252000 gwei=0.000252 ETHFee = 21000 \times (10 + 2) = 252000\ gwei = 0.000252\ ETH

Sender transactions cannot set baseFee. The protocol computes it deterministically from the parent block.

VariableWhat It MeansWho/What Decides ItNotes
BaseFee_parentBase fee in the parent blockProtocol consensus (computed from previous block state)Not manually chosen by validators; every node derives the same value.
GasUsed_parentTotal actual execution gas consumed in the parent blockEmerges from real transaction execution in that blockThis is the chain-wide actual gas used by included transactions.
GasLimit_parentParent block gas limit ceilingValidator/proposer proposes updates within protocol bounds; consensus rules enforce validityCan change gradually, not arbitrarily in one block.
ElasticityMultiplierMultiplier that defines target vs max block gasProtocol constant from EIP-1559On Ethereum mainnet this is 2, so target is half of gas limit.
GasTarget_parentTarget gas level used for base fee adjustmentDeterministically derived by protocol formulaComputed as GasLimit_parent / ElasticityMultiplier, not manually set.
BaseFee_nextBase fee for the next blockProtocol consensus calculationEvery client computes the same next value using integer arithmetic rules.

Conceptual update rule:

BaseFeenext=BaseFeeparent×(1+GasUsedparentGasTargetparentGasTargetparent×18)BaseFee_{next} = BaseFee_{parent} \times \left(1 + \frac{GasUsed_{parent} - GasTarget_{parent}}{GasTarget_{parent}} \times \frac{1}{8}\right)

With:

GasTargetparent=GasLimitparentElasticityMultiplierGasTarget_{parent} = \frac{GasLimit_{parent}}{ElasticityMultiplier}

Important implementation note:

  • Clients compute this using integer arithmetic and guardrails (no floating-point in consensus logic).
  1. If parent.GasUsed == parentGasTarget, base fee stays unchanged.
  2. If parent.GasUsed > parentGasTarget, base fee increases (with minimum increment guard).
  3. If parent.GasUsed < parentGasTarget, base fee decreases (bounded at zero).

When gas limit is around 30,000,000 and elasticity multiplier is 2:

  • Target gas is about 15,000,000.
  • GasLimit is about 30,000,000.
  1. GasUsed = GasTarget: base fee unchanged.
  2. GasUsed = 2 * GasTarget: base fee increases by up to about 12.5%.
  3. GasUsed = 0: base fee decreases by up to about 12.5%.

Assume:

  • BaseFee_parent = 100 gwei
  • GasTarget_parent = 15,000,000
  • GasUsed_parent = 22,500,000

Then:

GasUsedGasTargetGasTarget=22.51515=0.5\frac{GasUsed-GasTarget}{GasTarget} = \frac{22.5-15}{15} = 0.5

Adjustment factor:

0.5×18=0.06250.5 \times \frac{1}{8} = 0.0625

Conceptual result:

BaseFeenext=100×(1+0.0625)=106.25 gweiBaseFee_{next} = 100 \times (1 + 0.0625) = 106.25\ gwei

In execution, clients round by integer-wei math per consensus rules.

The 3 gas fields users set in type-2 transactions:

FieldDescription
gasLimitMaximum gas units the transaction is allowed to consume.
maxFeePerGasMaximum total price per gas unit you are willing to pay.
maxPriorityFeePerGasMaximum validator tip per gas unit.
  • You only pay for gasUsed, not all of gasLimit.
  • The execution-layer affordability bound before execution is:
value+gasLimit×maxFeePerGasvalue + gasLimit \times maxFeePerGas
  • For type-3 transactions, affordability also includes blob-fee allowance:
value+gasLimit×maxFeePerGas+blobGasUsed×maxFeePerBlobGasvalue + gasLimit \times maxFeePerGas + blobGasUsed \times maxFeePerBlobGas
  • For type-2 transactions, the final charged transaction fee is:
actualFeePaid=gasUsed×effectiveGasPriceactualFeePaid = gasUsed \times effectiveGasPrice
  • For type-3 transactions, total charged fee includes execution gas plus blob gas:
actualFeePaid=gasUsed×effectiveGasPrice+blobGasUsed×blobBaseFeeactualFeePaid = gasUsed \times effectiveGasPrice + blobGasUsed \times blobBaseFee
  • Conceptually, unused allowance can be viewed as:
unusedAllowance=gasLimit×maxFeePerGasgasUsed×effectiveGasPriceunusedAllowance = gasLimit \times maxFeePerGas - gasUsed \times effectiveGasPrice
  • Type-3 transactions also have blob-fee headroom:
blobAllowanceRemainder=blobGasUsed×(maxFeePerBlobGasblobBaseFee)blobAllowanceRemainder = blobGasUsed \times (maxFeePerBlobGas - blobBaseFee)

Refund behavior:

  • If gasLimit is higher than gasUsed, unused gas is not charged.
  • For EIP-1559 transactions, the difference between your maximum allowance and actual fee is never paid.

Key rules:

  • Upfront affordability: the sender must have enough ETH to cover value + gasLimit * maxFeePerGas before execution starts.
  • Out of gas: if execution exhausts gas, the transaction fails/reverts, but gas spent is still charged.

gas image

Example for out of gas

Imagine you are trying to execute a complex smart contract interaction, but you set your gas limit too low.

  • Gas Required by Contract: 80,00080,000 units
  • Your Gas Limit: 50,00050,000 units
  • Base Fee: 20 Gwei20 \text{ Gwei}
  • Priority Fee: 2 Gwei2 \text{ Gwei}

Step 1: The EVM Execution

The EVM starts processing the transaction. It completes the first few operations, consuming gas along the way. Once it hits 50,00050,000 units, it realizes it needs more to finish but is blocked by your limit.

Step 2: The Revert

The transaction halts. The EVM reads “Out of Gas,” cancels the execution, and reverts the state.

Step 3: The Charge

Even though it failed, the network charges you for the 50,00050,000 units of work it performed:

  1. Calculate Effective Gas Price: 20 Gwei+2 Gwei=22 Gwei20 \text{ Gwei} + 2 \text{ Gwei} = 22 \text{ Gwei}
  2. Calculate Total Cost in Gwei: 50,000×22 Gwei=1,100,000 Gwei50,000 \times 22 \text{ Gwei} = 1,100,000 \text{ Gwei}
  3. Convert to ETH: 1,100,000/109=0.0011 ETH1,100,000 / 10^9 = 0.0011 \text{ ETH}

You lose 0.0011 ETH0.0011 \text{ ETH}, and the transaction fails.

You can use the interactive calculator below to explore how different limits and network fees impact the cost of both successful and Out of Gas transactions.

  • Validator/proposer receives priority-fee portion on used gas.
  • Under EIP-1559, validator payout excludes base fee.
  • Under EIP-4844, blob base fee is also burned (not paid to validator).
  • Base fee on used gas is removed from supply.
  • It is not credited to validator balance.
# EIP-1559 burn accounting (conceptual)
burn_amount = gas_used * base_fee_per_gas
validator_tip = gas_used * effective_priority_fee_per_gas
total_deduction = burn_amount + validator_tip # total fee
sender_balance -= total_deduction # fee charged
total_supply -= burn_amount # permanently burned
validator_balance += validator_tip
# EIP-4844 extension (type-3)
blob_burn_amount = blob_gas_used * blob_base_fee_per_gas
total_supply -= blob_burn_amount

Part 4: ETH Supply and Burn Dynamics (EIP-1559)

Section titled “Part 4: ETH Supply and Burn Dynamics (EIP-1559)”

ETH scarcity is a dynamic balance:

ΔSupply=New IssuanceBurn Amount\Delta Supply = New\ Issuance - Burn\ Amount
  • Ethereum issues new ETH to pay validators for consensus security.
  • A common recent magnitude is roughly ~2,700 ETH/day, but this is not fixed.
  • Issuance scales with validator participation; in simplified terms, aggregate issuance grows sublinearly (approximately with the square root of total ETH staked).

Assume:

  • Active validators = 600,000
  • Effective balance per validator (example assumption) = 32 ETH = 32 * 10^9 gwei

Formula:

BaseReward=EffectiveBalance×64TotalActiveBalance×4BaseReward = \frac{EffectiveBalance \times 64}{\sqrt{TotalActiveBalance} \times 4} ProposerShareattestations×18×BaseRewardProposerShare \approx attestations \times \frac{1}{8} \times BaseReward ValidatorRewardmax78×BaseReward+priorityfeevalidatorsValidatorReward_{max} \approx \frac{7}{8} \times BaseReward + \frac{priority fee}{validators}

Thus,

Newissuance=ProposerShare+ValidatorRewardpriorityfeeNew issuance = ProposerShare + ValidatorReward - priority fee
  • For each included transaction, the protocol burns the base-fee portion:
Burn=gasUsed×baseFeeBurn = gasUsed \times baseFee
  • High activity periods can push burn above issuance (net deflation).
  • Lower L1 fee periods, including periods of higher activity on L2 after Dencun blob scaling, can reduce L1 burn below issuance (mild net inflation).

ETH Supply in real-time: ETH supply

References: 1, 2, 3, 4, 5

Guardrail intuition (economic, not a hard protocol invariant)

Section titled “Guardrail intuition (economic, not a hard protocol invariant)”
  • ETH is not expected to mechanically burn to zero in practice.
  • If ETH becomes very scarce, validator yields and market dynamics can incentivize more staking and dampen fee-burning demand growth.

Reference: 1

Part 5: The Dual-Token Model (Alternative Approach)

Section titled “Part 5: The Dual-Token Model (Alternative Approach)”

Some chains use a two-token structure (for example, VeChain VET/VTHO and NEO/“GAS”):

  • Primary token: governance, staking, and core network value.
  • Secondary token: utility gas token used for fees and often burned.

Reference: 1

  • Separating the gas token can reduce fee volatility for users and enterprises.
  • This can improve operating-cost predictability when gas-token policy is actively managed.
  • Decoupling fee burn from the primary token can weaken direct value-capture feedback to the primary asset.
  • In practice, this may reduce alignment between network usage and primary-token scarcity, depending on chain design and governance.