Ethereum Virtual Machine (EVM)
The runtime environment for smart contracts on Ethereum and compatible chains
What is the EVM?
The Ethereum Virtual Machine (EVM) is a computation engine that acts as the runtime environment for smart contracts on Ethereum. It has become the de facto standard for blockchain execution environments.
How It Works
Stack-Based Architecture
- 256-bit word size
- Maximum stack depth of 1024
- Operations consume gas
Memory Model
- Stack: Temporary computation space
- Memory: Volatile, byte-addressable
- Storage: Persistent, key-value store
Execution Flow
- Transaction triggers contract function
- EVM loads contract bytecode
- Opcodes execute sequentially
- State changes recorded if successful
Opcodes
The EVM has approximately 140 opcodes:
| Category | Examples |
|---|---|
| Arithmetic | ADD, MUL, SUB, DIV |
| Logic | AND, OR, XOR, NOT |
| Stack | PUSH, POP, DUP, SWAP |
| Memory | MLOAD, MSTORE |
| Storage | SLOAD, SSTORE |
| Control | JUMP, CALL, RETURN |
Gas Mechanism
Every operation costs gas:
- Prevents infinite loops
- Compensates validators
- Prioritizes transactions
EVM Compatibility
Many chains are EVM-compatible:
- Arbitrum: Optimistic rollup on Ethereum
- Polygon: Ethereum sidechain/L2
- Avalanche C-Chain: High-speed L1
- BNB Chain: Binance’s EVM chain
- Base: Coinbase’s L2
Benefits of EVM Compatibility
- Developer Familiarity: Use existing tools
- Code Reuse: Deploy same contracts
- Ecosystem Access: Leverage Ethereum tooling
- Interoperability: Bridge assets easily