How Is the Actual ‘Gas Used’ Calculated for a Smart Contract Execution?

The 'Gas Used' is calculated by summing the pre-defined gas cost for every operation (opcode) executed by the Ethereum Virtual Machine (EVM) during the transaction. Different opcodes, such as storage writes, reads, or simple arithmetic, have different fixed gas costs.

The total sum reflects the computational effort required.

What Is the Role of the ‘EVM’ (Ethereum Virtual Machine) in Gas Consumption?
How Does the Complexity of a Smart Contract Affect the Required Gas Limit?
Why Do Storage Operations (SSTORE) Cost More Gas than Simple Calculations?
What Is the Significance of the Ethereum Virtual Machine (EVM)?
What Is the Difference between ‘Intrinsic Gas’ and ‘Execution Gas’?
How Does the ‘Calldata’ Size Affect the Gas Cost of a Transaction?
What Is the Concept of ‘Gas Optimization’ in Smart Contract Development?
What Does ‘Turing-Complete’ Mean in the Context of the EVM?

Glossar