How Does the EVM Calculate the Gas Cost of a Specific Operation?
The Ethereum Virtual Machine (EVM) assigns a fixed gas cost to every low-level operation (opcode). When a smart contract is executed, the EVM sums the gas costs of all opcodes performed.
For storage operations, the cost can be higher due to the permanent state change. This calculation is deterministic and ensures fair resource allocation.