Introduction to Gas
Gas in Ethereum measures the computational resources required to execute smart contracts and transactions. It serves three key purposes:
- Preventing network abuse
- Ensuring efficient transaction processing
- Maintaining network health through fair resource allocation
Each operation consumes a specific amount of Gas, paid for by users via GasPrice. Think of Ethereum as a worker - Gas represents the labor expended, while GasPrice is the wage per unit of work.
Key Gas Concepts
- GasLimit: Maximum units of work you're willing to pay for
- GasUsed: Actual units consumed (excess Gas gets refunded)
- GasPrice: Dynamic price per unit set by the network
EIP-1559 Transaction Structure
A typical EIP-1559 transaction contains these components:
| Component | Description |
|---|---|
| Gas Limit & Usage | Shows GasLimit vs actual consumption |
| Gas Fees | Includes Base and Priority fees |
| Burnt Fees | Portion permanently removed from circulation |
| Txn Savings | Difference between max and actual fees |
Example transaction type: 2 (EIP-1559) as defined by EIP-2718.
BaseFee Mechanism
Introduced by EIP-1559, BaseFee dynamically adjusts to network congestion. Key characteristics:
- Automatically recalculates every block
- Burns the BaseFee portion
- Increases when network is busy
- Decreases when network is idle
Calculation Formula
BaseFee change = parentBaseFee * (GasUsedDelta / parentGasTarget) / 8Where:
parentGasTarget= parent block's GasLimit / 2 (~15M)GasUsedDelta= difference between actual and target usage
๐ See live BaseFee adjustments on Etherscan
Priority Fees (MaxPriorityFeePerGas)
This voluntary tip to miners determines transaction priority. Key points:
- Paid directly to miners
- Higher values = faster processing
- Current rates visible via GasTracker
- Final GasPrice = BaseFee + PriorityFee
MaxFee Protection
The maximum price users are willing to pay, calculated as:
MaxFee = (2 * BaseFee) + MaxPriorityFeeThis ensures transactions remain valid through multiple blocks even if BaseFee rises.
Fee Economics
Burnt Fees
- Calculated as
BaseFee * GasUsed - Permanently removed from circulation
- Deflationary mechanism for ETH
Transaction Savings
Savings = (MaxFee * GasUsed) - Actual Fee PaidJSON-RPC Methods
Developers can access Gas parameters through these Ethereum node methods:
eth_estimateGas
- Estimates required GasLimit
- Returns in hexadecimal format
eth_maxPriorityFeePerGas
- Provides current recommended tip
- Helps set competitive PriorityFee
eth_getBlockByNumber
- Returns latest block data
- Includes current BaseFee
๐ Learn more about Ethereum's fee market
FAQs
Why did Ethereum implement EIP-1559?
To create more predictable gas fees and introduce a deflationary mechanism through fee burning.
How often does BaseFee change?
Every block (approximately every 12-15 seconds).
What happens if I set MaxPriorityFee too low?
Your transaction may take longer to process or get stuck during network congestion.
How is the burnt fee calculated?
Burnt Fee = BaseFee * GasUsed in the transaction.
Can I get a refund if BaseFee decreases?
Yes, you'll pay the current lower rate and receive the difference back.
Why use MaxFee instead of just GasPrice?
MaxFee protects against sudden BaseFee spikes while still allowing you to benefit from decreases.