BeCuriouzBeCuriouz

Learn something new every day

⛓️ Crypto & Blockchain
⛽

Why every Ethereum transaction has a fuel gauge

💡 Gas meters every operation a transaction performs; if it runs out you lose your changes but still pay for the computation already done.

On Ethereum, running code isn't free — and the reason is a clever unit called gas. Every low-level operation the network can perform (adding two numbers, storing a value, hashing data) has a fixed gas cost. Adding numbers is cheap; permanently writing to storage is expensive. When you send a transaction, you're really buying computation, and gas is how the network meters it — like a taxi fare that ticks up per operation instead of per mile.

When you submit a transaction you set two things: a gas limit (the most units you're willing to consume) and a gas price (how much you'll pay per unit, in tiny fractions of ETH called gwei). Your fee is simply gas used × gas price. The gas limit exists mainly as a safety cap so a buggy or malicious contract can't loop forever and drain your wallet — the machine just stops when the meter hits the limit.

Here's the counterintuitive part: if your transaction runs out of gas before finishing, the network undoes all its changes (an out-of-gas revert) — but you still pay for every unit consumed up to that point. The work is thrown away; the fee is not. This is deliberate: the validators spent real computing effort, so they must be compensated whether or not your transaction succeeded. Any unused gas below your limit, however, is returned to you.

⛽ Why every Ethereum transaction has a fuel gauge — BeCuriouz