Gas is a 'sub-currency' which enables the EVM and Ethereum's decentralised computer to run -- with each operation, an amount of gas (proportional to the computational effort required to perform the operation) is consumed.

Gas is required to pay for all operations performed on the blockchain. The Ether used to pay for gas goes to the miner that performs the given computation, in order to reimburse them for the energy used. The price of operations, in gas per opcode, was defined in the yellow paper, in a way that the amount of gas consumed is proportional to the computational effort required to perform the operations.

Gas-related user defined values include:

  • block gas limit: maximum amount of gas to be consumed within a block. Acts as a limit on how many computations can be completed per block. Defined by miners.

  • transaction gas limit: maximum amount of gas allowed to be consumed by a given transaction/operation. Acts as a limit on the amount of computation time an individual contract can use. Defined by user when sending each transaction.

  • gas price: price, in Ether/gas, that a user is willing to pay. Defined by user when sending each transaction.

Requiring users to pay for gas is an anti-DoS mechanism in Ethereum. Otherwise dishonest users could have the miners perform computationally difficult tasks for no benefit to anyone. From the whitepaper:

The intent of the fee system is to require an attacker to pay proportionately for every resource that they consume, including computation, bandwidth and storage; hence, any transaction that leads to the network consuming a greater amount of any of these resources must have a gas fee roughly proportional to the increment.

history | excerpt history