Ethereum Virtual Machine (EVM)

The Ethereum Virtual Machine (EVM) is the software environment, run by every Ethereum node, that executes smart contract code and updates the blockchain's state in the same deterministic way on every machine.

When a transaction calls a smart contract, every Ethereum node runs the same code in its own copy of the EVM and must reach the same result, so the network agrees on the new state. Developers write contracts in languages such as Solidity or Vyper, which compile into bytecode, a sequence of low-level instructions called opcodes. The EVM is stack-based, and each opcode has a gas cost. Gas caps how much computation a transaction can use, which stops endless loops from stalling the network.

For users, the EVM is why gas fees exist and why many networks feel familiar. Many layer 2 rollups and other blockchains are EVM-compatible, so the same wallet, address format and contract code work across them. For example, swapping tokens on a decentralized exchange sends a transaction that tells the EVM to run the exchange contract's swap function. The EVM checks balances, moves the tokens and records event logs. If a condition fails, it reverts the whole transaction, and the gas already used is still paid.

A common misconception is that EVM compatibility means networks are connected. The same address can exist on several EVM chains, but the balances on each chain are separate, and tokens sent on the wrong network do not automatically appear on another. The EVM also executes code exactly as written. If a contract contains a bug or a malicious function, the EVM will carry it out faithfully.

Learn more

Related terms