Gas & Fees: Paying for Shared Computation
Every node runs your transaction, so it isn’t free — gas meters the work, pays the producers, blocks spam, and auctions scarce space.
You go to make a tiny transaction and the network demands a surprisingly large “gas fee” — sometimes more than the amount you’re sending. It feels like a rip-off, especially since the same transaction was nearly free yesterday. Where does this fee actually go, why does it swing so wildly, and is someone gouging you? Hold the question; by the end you’ll see exactly what you’re paying for.
Gas: paying for work the whole network does
When you send a transaction or call a contract, every node executes it and stores the result, consuming real computation and storage. Gas is the unit that measures how much of those resources your action uses. Your fee is roughly gas used × the price you pay per gas. A simple transfer uses little gas; a complex contract call uses more.
That fee goes to the block producers (the miners or validators from lesson 7) as payment for including your transaction and continuing to secure the chain. It’s the price of using a shared, secured machine.
Fees also stop spam and runaway code
Charging per unit of computation does a second job: it makes denial-of-service attacks and infinite loops uneconomical. Because every step costs gas, an attacker can’t cheaply flood the network, and a contract with an endless loop doesn’t hang every computer on Earth — it simply runs until it exhausts the gas you paid, then halts.
So “a program that could run forever” becomes “a program that runs out of gas and stops.” Paying per step turns an unbounded risk into a bounded, prepaid cost.
Metering an infinite loop: • A contract contains a loop with no exit — left alone it would run forever. • But each iteration consumes gas, and the caller only paid for so much. • The loop runs… until the gas is used up, at which point the network stops execution and reverts it. • The attacker just wasted their own fee; every node moves on. The threat is priced out, not policed out.
Why fees spike: a market for limited space
Each block holds only so many transactions — block space is finite. When more people want in than fit, they compete by bidding higher fees, and producers naturally include the highest bidders first. So fees rise with demand and fall when it’s quiet — a live auction for scarce space, not arbitrary gouging.
This is why the same transaction can cost pennies at midnight and a fortune during a frenzy: the work didn’t change, but you’re bidding against everyone else for a limited seat. You can see the going rate and choose to pay more (faster) or wait. Persistently high fees are a real signal — that capacity is tight — which is the scaling problem we’ll tackle in Module 4. Not doom; a pricing problem with active solutions.
Gas is like postage that’s also a rush-hour toll. You pay by the size of what you send — a postcard costs less than a heavy parcel (gas used) — and the money goes to the carriers who do the work. But the road has limited lanes: when everyone drives at once, the express lane goes to whoever pays the higher toll, so prices surge at rush hour and fall at midnight. No one’s gouging — a scarce road is being auctioned in real time. And because every mile is metered, no one can send a truck that drives forever: it stops when the toll money runs out.
Why an identical transfer costs different amounts: 1. You send a basic token transfer that uses a fixed 21,000 units of gas. 2. You pick a gas price; your fee = 21,000 × that price, and a higher price gets you included sooner. 3. Late at night the network is quiet, so a low price lands you in the very next block, cheaply. 4. The next day a popular sale floods the network; thousands compete for limited block space and bid the price up. 5. Now the same 21,000-gas transfer costs far more — not because the work changed, but because you’re out-bidding a crowd for a scarce seat. Wait an hour and the price drops. Same action, market-driven price.
This is the reading. The interactive version — active-recall quiz, a hands-on experiment you run in your own AI, and an earned mastery check — is free in the app.
Start this lesson free →