Gas — Paying for Computation
Asha's call to release is executed by thousands of nodes. If contract calls were free, anyone could send one containing an endless loop, and every node would spin forever. Gas is how Ethereum and the other EVM chains prevent that: every step of computation has a price, and the sender pays it.
The rule
Every step costs gas; the fee is gas used times the price per gas.
- Gas units measure work. Each EVM operation has a fixed gas cost: adding two numbers is cheap, writing to storage is expensive. A plain ETH transfer between two ordinary accounts costs exactly 21,000 gas.
- Gas limit. The sender sets the most gas the transaction may use. If execution needs more, it stops with out of gas: every change reverts, and the whole gas limit is spent.
- Gas price. The native coin paid per unit of gas, quoted in gwei, one billionth of an ETH. On Ethereum it has two parts: a base fee set by the protocol, which rises when blocks are busier than a target and is burned, plus a priority fee, or tip, which goes to the validator.
- Unused gas is refunded. When a call finishes, or fails a
requirecheck, you pay for the gas actually used, not the whole limit.
Each block has a gas limit too, so gas also measures how much of the scarce space in a block you take up. When demand is high, the base fee climbs and cheaper transactions wait.
The shortcut
For fee questions: multiply gas used by gwei per gas, then divide by 1,000,000,000 to get ETH.
Gas used
The call used 50,000 gas.
The trap is setting the gas limit too low to save money. The call runs out of gas, nothing it tried to do takes effect, and the gas is spent anyway. Wallets estimate gas by simulating the call first for exactly this reason.
Drills
Answer fast — trust the rule.
How much gas does a plain ETH transfer between two ordinary accounts use?
A transaction uses 30,000 gas at 10 gwei per gas. What is the fee in gwei?
A call runs out of gas halfway through. What happens?
Why do EVM chains charge for computation at all?
The base fee is 25 gwei and the tip is 1 gwei. A transaction uses 40,000 gas. How much of its fee is burned?
Remember
- Every step costs gas; the fee is gas used times the price per gas.
- Shortcut: gas times gwei, then divide by 1,000,000,000 for ETH. The base fee is burned and the tip goes to the validator.
- Trap: a limit that is too low still costs you. Out of gas reverts everything and keeps the fee.
