Gas, Fees, and How Transactions Cost Money
Every interaction with Ethereum — a transfer, a contract call, deploying a new contract — costs something, and this lesson covers exactly how that cost is calculated and where the money actually goes.
Gas as a unit of computational effort. As covered in Module 2's lesson on the EVM, every opcode a transaction triggers has a defined gas cost. "Gas" is simply the unit that measures how much computational work a transaction requires — a simple ETH transfer has a small, fixed gas cost (21,000 gas, specifically), while a complex contract interaction involving multiple storage writes and calls to other contracts can require hundreds of thousands of gas or more. The total cost of a transaction, in ETH, is gas used multiplied by the price you pay per unit of gas.
Gas price, denominated in gwei. The price per unit of gas is denominated in gwei, a small fraction of ETH (one gwei equals one billionth of an ETH, or 0.000000001 ETH). Denominating gas prices in gwei rather than in whole ETH simply makes the numbers more human-readable — a typical gas price might be in the range of single or double-digit gwei during normal network conditions, rising substantially during periods of high demand.
Why every block has a gas limit. Each block has a target amount of gas it aims to use, and a hard ceiling it cannot exceed, set by the protocol and adjustable only gradually over time by validators collectively. This cap exists for the same reason Layer 1 throughput stays modest generally (covered in Module 5): a block that could contain unlimited computation would take longer to download, verify, and propagate across the network, which would make it harder for ordinary nodes to keep up and would undermine the broad, accessible verification that keeps the network trustworthy.
EIP-1559: base fee and priority fee. Since the EIP-1559 upgrade, every transaction's total fee splits into two distinct parts. The base fee is calculated automatically by the protocol based on how full recent blocks have been, and it is burned — destroyed, removed from circulating supply — rather than paid to the validator who includes the transaction. This base fee adjusts up when blocks are consistently fuller than the network's target and down when they're consistently emptier, which is the protocol's built-in mechanism for managing demand rather than relying purely on an open auction. The priority fee (often called a "tip") is an additional amount the sender chooses to offer, which goes directly to the validator who includes the transaction — a higher tip gives a transaction a better chance of being included promptly during periods of competition for block space. Finally, a sender sets a max fee: a ceiling on the total amount (base fee plus tip) they're willing to pay per unit of gas. If the actual base fee at the time of inclusion is lower than the max fee allows, the sender only pays the actual base fee plus their tip — not the full max fee — and any difference is simply not charged.
Why this design replaced a pure first-price auction. Before EIP-1559, Ethereum used a simpler model where every sender simply bid a gas price, and the highest bidders were included first — a model that made fees difficult to estimate accurately, since a sender had to guess what everyone else was bidding at that exact moment. The base fee's automatic, predictable adjustment based on recent block fullness gives senders (and the wallets that estimate fees on their behalf) a much more reliable baseline to work from, with the priority fee left as the smaller, genuinely competitive component for anyone who wants faster inclusion specifically.
Putting it together. A transaction's total cost in ETH equals: gas used, multiplied by (base fee plus priority fee), where the base fee portion is burned and the priority fee portion goes to the validator. This is directly relevant to the previous lesson's discussion of ETH's variable supply: every transaction's base fee burn is one half of the two forces (issuance and burning) that determine whether ETH's net supply grows or shrinks in any given period. A transaction that fails or reverts partway through execution still consumes the gas used up to the point of failure, and that gas is still paid for — a point worth knowing, since a poorly constructed transaction can cost real money even when it doesn't achieve what the sender intended.
Worked Example
Open a modern wallet's transaction confirmation screen before sending a transaction. Most wallets display three distinct numbers: an estimated gas amount (how much computational work the transaction is expected to require), the current network base fee (per unit of gas, usually shown in gwei), and a tip you can adjust (your offered priority fee). The wallet combines these into an estimated total cost, and often a maximum cost reflecting your set max fee ceiling — seeing all three numbers together on one confirmation screen makes the abstract gas-times-price formula concrete.
estimated cost = gas_used × (base_fee + priority_fee)
Exercise
Find one transaction on a block explorer and break down its total fee into the base fee portion (burned) and the priority fee portion (paid to the validator). Note the split between the two — most block explorers show this breakdown directly on a transaction's detail page.
Recap
- Gas measures computational effort; the total cost of a transaction is gas used multiplied by the price paid per unit of gas, denominated in gwei.
- Since EIP-1559, every transaction's fee splits into a base fee (burned, adjusts automatically with network demand) and a priority fee (a tip paid directly to the validator).
- A sender sets a max fee as a ceiling; they only pay the actual base fee plus tip at the time of inclusion, never more than that ceiling allows, and a failed transaction still consumes and pays for the gas used before it failed.
Resources
- EIP-1559 Specification — the primary source defining the base fee and priority fee mechanism.
- Ethereum.org: Gas and Fees — official documentation on gas, gwei, and fee estimation.
- Etherscan Gas Tracker — live gas prices and a breakdown of recent transaction fees.