The EVM is the runtime environment that executes smart contract bytecode on Ethereum. It is a stack-based, Turing-complete virtual machine that runs identically on every Ethereum node, ensuring all nodes reach the same result for every transaction. The engine that makes Ethereum programmable, without it, Ethereum would only handle simple transfers like Bitcoin.
What Is the EVM (Ethereum Virtual Machine)?
3 min read
The short version
The EVM is Ethereum's shared computer. When you call a smart contract, every node worldwide runs the same code on the same inputs and must get the same answer. Like a calculator that thousands of people use simultaneously, they all type the same buttons and all get the same number. This consensus on computation is what makes smart contracts trustless.
How It Works
The EVM processes bytecode instructions (opcodes) using a 256-bit word size stack architecture. Key properties: (1) Deterministic, no randomness, no external I/O, no threads. Same input always produces same output. (2) Isolated, contracts cannot access the file system, network, or other processes. They can only read blockchain state and call other contracts. (3) Metered, every opcode has a fixed gas cost, preventing infinite loops and DoS attacks. (4) World state, the EVM operates on a global state (all account balances and contract storage), producing a new state after each transaction. Opcodes include: arithmetic (ADD, MUL), stack operations (PUSH, POP, DUP), memory/storage (MLOAD, SSTORE), control flow (JUMP, JUMPI), environmental data (CALLER, CALLVALUE, TIMESTAMP), and inter-contract calls (CALL, DELEGATECALL, STATICCALL). SSTORE (writing to persistent storage) is the most expensive operation at 20,000 gas for a new slot.
What happens when you call a contract function
You call transfer(0xBob, 100) on a USDC contract. (1) Your transaction enters a block. (2) The EVM loads the USDC contract bytecode. (3) It decodes calldata to identify the function selector (first 4 bytes of keccak256("transfer(address,uint256)")). (4) It jumps to the transfer function logic. (5) It executes: reads your balance from storage (SLOAD, 2,100 gas), checks balance >= 100, subtracts 100 from your balance, adds 100 to Bob's balance, writes both to storage (SSTORE, 5,000 gas each for warm slots). (6) Emits Transfer event. (7) Returns success. Total: ~65,000 gas. Every node does this identically and agrees on the new state.
What People Get Wrong
The EVM is one computer somewhere
The EVM is a specification, not physical hardware. Every Ethereum node runs its own implementation (Geth in Go, Reth in Rust, Nethermind in C#), but all implementations produce identical results because they follow the same spec.
EVM-compatible means identical to Ethereum
Chains like Polygon, Arbitrum, BSC, and Avalanche are "EVM-compatible", they run the same bytecode. But they may differ in gas costs, opcode behavior at the edges, precompiles, and consensus mechanisms. Code that works on Ethereum usually works on them, but subtle differences can cause issues.
The EVM can run any program
It is Turing-complete (can express any computation) but practically limited by gas. It cannot make HTTP requests, access files, or generate randomness. It operates purely on on-chain state and transaction inputs.
Keep Reading
Sources & Further Reading
- Ethereum.org: EVM
Official documentation of the Ethereum Virtual Machine architecture
- EVM Opcodes Reference
Interactive reference of all EVM opcodes with gas costs and descriptions
- Ethereum Yellow Paper
Formal specification of the EVM by Dr. Gavin Wood
Questions People Also Ask
- What languages compile to EVM bytecode?
- Solidity (most popular, C-like), Vyper (Python-like, simpler), Huff (low-level, near-assembly), and Fe (Rust-like, experimental). All compile to the same EVM bytecode that nodes execute.
- What is the EVM word size?
- 256 bits (32 bytes). That is why Ethereum natively handles 256-bit integers, which is unusually large compared to traditional 32/64-bit systems. It makes cryptographic operations (hashing, signatures) efficient within the VM.
- Will the EVM be replaced?
- There are proposals (eWASM, EOF) to evolve the EVM with better safety features and performance. But full replacement is unlikely in the near term due to the massive ecosystem of existing contracts, tooling, and developer knowledge built around the current EVM.