Fiveable

💱Blockchain and Cryptocurrency Unit 8 Review

QR code for Blockchain and Cryptocurrency practice questions

8.4 Gas, Ether, and the Ethereum Virtual Machine (EVM)

8.4 Gas, Ether, and the Ethereum Virtual Machine (EVM)

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
💱Blockchain and Cryptocurrency
Unit & Topic Study Guides

Gas, Ether, and the EVM are crucial components of Ethereum's ecosystem. Gas measures computational effort, with transactions and smart contracts consuming gas. Ether, the network's native currency, is used to pay for gas, with Wei and Gwei as smaller denominations.

The Ethereum Virtual Machine (EVM) is the heart of smart contract execution. It provides a consistent environment across all nodes, using a stack-based architecture with its own instruction set. The EVM's memory model includes stack, memory, and storage for efficient contract operations.

Gas and Fees

Gas as a Unit of Computation

  • Gas represents the computational effort required to execute operations on the Ethereum network
  • Every transaction and smart contract execution consumes a certain amount of gas
  • Gas is used to measure and allocate the computational resources needed for each operation
  • Complex operations (storage writes) consume more gas compared to simpler ones (additions)

Denominations of Ether

  • Wei is the smallest denomination of Ether, where 1 Ether = 10^18 Wei
    • Allows for precise calculations and avoids dealing with decimal points
  • Gwei (Gigawei) is another commonly used denomination, where 1 Gwei = 10^9 Wei
    • Often used to express gas prices in a more readable format (20 Gwei instead of 20,000,000,000 Wei)
Gas as a Unit of Computation, What happens in DAOs when Gas price raises in Ethereum blockchain?

Transaction Fees and Gas Management

  • Gas price represents the amount of Ether per unit of gas the sender is willing to pay for the transaction
    • Higher gas prices incentivize miners to prioritize the transaction
  • Gas limit sets the maximum amount of gas the sender is willing to consume for the transaction
    • Prevents infinite loops or excessive resource consumption
  • Unspent gas is refunded to the sender, while the consumed gas is paid to the miner as a transaction fee
  • Senders must carefully set the gas price and limit to ensure successful and cost-effective transaction execution

Ethereum Virtual Machine (EVM)

Gas as a Unit of Computation, Overview | CMB

EVM Architecture and Execution Environment

  • The Ethereum Virtual Machine (EVM) is a stack-based, isolated execution environment for smart contracts
  • Provides a runtime environment for executing Ethereum smart contracts across all nodes in the network
  • Ensures deterministic and consistent execution of smart contracts, regardless of the underlying hardware or operating system
  • Maintains a stack, memory, and storage for each contract execution

EVM Instruction Set and Opcodes

  • EVM has its own instruction set, consisting of opcodes that perform specific operations
  • Opcodes include arithmetic operations (ADD, SUB), stack manipulations (PUSH, POP), and storage access (SSTORE, SLOAD)
  • Each opcode has an associated gas cost, reflecting its computational complexity and resource usage
  • Smart contract code is compiled into EVM bytecode, which is a sequence of opcodes executed by the EVM

EVM Memory and Storage Model

  • EVM has three main data locations: stack, memory, and storage
  • The stack is a last-in-first-out (LIFO) data structure used for holding temporary values and managing execution flow
    • Most opcodes operate on the stack, pushing and popping values as needed
  • Memory is a byte-addressable, volatile storage area used for temporary data during contract execution
    • Provides a linear memory model for storing and accessing data within a single transaction
  • Storage is a persistent key-value store for long-term data that persists across transactions and contract invocations
    • Allows contracts to store and retrieve data across different function calls and transactions
Pep mascot
Upgrade your Fiveable account to print any study guide

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Click below to go to billing portal → update your plan → choose Yearly → and select "Fiveable Share Plan". Only pay the difference

Plan is open to all students, teachers, parents, etc
Pep mascot
Upgrade your Fiveable account to export vocabulary

Download study guides as beautiful PDFs See example

Print or share PDFs with your students

Always prints our latest, updated content

Mark up and annotate as you study

Plan is open to all students, teachers, parents, etc
report an error
description

screenshots help us find and fix the issue faster (optional)

add screenshot

2,589 studying →