Level 3 · How it worksThe village#218

The Ethereum Virtual Machine (EVM): every house does the same sum and must get the same answer

The EVM is the machine every Ethereum node runs to carry out smart contracts. It works through simple numbered instructions, each with a fixed gas price, and it is deterministic: the same input gives the same output on every computer, which is how thousands of nodes agree.

Grandma Rosa watches the village run a rule from the notebook. In every house, someone takes the same page, follows the same steps in the same order, and writes down the result.

"What if one house gets a different answer?" she asks. Then that house is wrong, and its page is thrown out. The whole system rests on every kitchen table doing the same sum and landing on the same number.

The steps they follow, and the rule book that says what each step means and what it costs, is the Ethereum Virtual Machine, the EVM. It isn't a machine you can touch. It's a shared set of instructions that every node runs in its own software.

What it is

ethereum.org calls the EVM "a decentralized virtual environment that executes code consistently and securely across all Ethereum nodes" (ethereum.org). The key property is the plainest one: "Given an input, it produces a deterministic output."

Formally, the EVM is a function, written Y(S, T) = S': take the current state S, apply a transaction T, get the new state S'. Every node runs that function on its own copy. In ethereum.org's words, "Every computer in the network must agree upon each new block and the chain as a whole" (ethereum.org). The machine was first specified in the Yellow Paper, released on 1 April 2014 (ethereum.org).

How it works

Programmers write contracts in a readable language. A compiler turns that into bytecode: a string of numbered instructions called opcodes, one byte each, sometimes followed by data. ethereum.org: "Compiled smart contract bytecode executes as a number of EVM opcodes" (ethereum.org).

The EVM is a stack machine: it works like a pile of plates, putting numbers on top and taking them off. The stack holds up to 1,024 items, each a 256-bit number.

Here is a tiny sum, (2 + 3) x 4, as bytecode: 0x6002600301600402. Gas prices per step are from ethereum.org's opcode table (ethereum.org):

  1. 60 02: PUSH1 2. Put 2 on the pile. 3 gas. Pile: 2.
  2. 60 03: PUSH1 3. Put 3 on top. 3 gas. Pile: 2, 3.
  3. 01: ADD. Take two, add them, put back the result. 3 gas. Pile: 5.
  4. 60 04: PUSH1 4. 3 gas. Pile: 5, 4.
  5. 02: MUL. Take two, multiply. 5 gas. Pile: 20.

Total: 3 + 3 + 3 + 3 + 5 = 17 gas, and the answer is 20 in every house. At the base fee of the house block, 0.137961262 gwei per gas (Etherscan, block 26,449,058, 19 November 2026), those five steps cost 2.345341454 gwei. Calling a contract at all costs more: every transaction starts at 21,000 gas, the specification's TX_BASE (execution specs).

Real contracts look the same, only longer. The WETH9 contract's bytecode on Etherscan begins 0x6060604052: PUSH1 0x60, PUSH1 0x40, MSTORE. Put two numbers on the pile, then store one in the machine's scratch memory (Etherscan).

Not every step is cheap. The specification sets 20,000 gas for writing a new value into a contract's permanent storage (STORAGE_SET). That's more than 6,600 additions. Arithmetic is pocket money; changing the notebook for good is the rent.

Why it matters

  • Agreement without a referee. Because the result depends only on the state and the transaction, nodes don't need to trust each other. They redo the work and compare.
  • No internet, no dice of its own. A contract can read what's in the notebook, such as the current block's timestamp, but it can't ask a website or invent a private random number. Anything from outside has to be written into the notebook first.
  • One machine, many chains. The EVM's design has been copied by other blockchains, which is why the same contract code can run there. "EVM-compatible chains explained" covers what that does and doesn't mean.

Where people get it wrong

  • "The EVM is a big computer somewhere." It's a set of rules that each node runs in its own software. There's no central machine to switch off.
  • "Verified source code is what runs." The bytecode is what runs. Verification on a block explorer means someone showed that the published source compiles to that exact bytecode.
  • "Gas prices for each step change with the market." The gas per step is fixed by the protocol and changes only with network upgrades. What moves is the price per unit of gas.
  • "Contracts can't loop forever, so they're safe." They can't loop forever because every step costs gas and the gas runs out. Safe is a different question.

Check what's behind the address

On any block explorer, open a contract you're about to use and look for "Contract Source Code Verified". No verified source means you're trusting bytecode nobody has shown you.

The EVM will run it either way, faithfully, in thousands of houses at once. It just won't tell you what it does.

Frequently asked questions

What is the Ethereum Virtual Machine?

The EVM is the shared set of instructions that every Ethereum node uses to run smart contracts. Given the same state and the same transaction, it always produces the same result, which is how all nodes agree on the new state after each block.

What is bytecode?

Bytecode is the compiled form of a smart contract: a string of one-byte instructions, called opcodes, that the EVM actually runs. Programmers write in a readable language, and a compiler turns it into bytecode stored on the blockchain.

What is an opcode?

An opcode is a single EVM instruction, such as ADD, MUL or PUSH1. Each has a fixed gas cost set by the protocol; for example, ethereum.org lists ADD at 3 gas and MUL at 5 gas.

Why does the EVM have to be deterministic?

Because thousands of nodes run every transaction independently and must reach exactly the same result. If a contract could produce different answers on different computers, the network couldn't agree on balances.

Why does every step in the EVM cost gas?

Gas puts a price on computation so that nobody can make every node run an endless or wasteful program for free. When a transaction's gas runs out, the work stops and its changes are undone.

Sources

  1. ethereum.org, Ethereum Virtual Machine (EVM)
  2. ethereum.org, Opcodes for the EVM
  3. Ethereum execution specifications, Osaka gas constants (diff from Prague)
  4. ethereum.org, Intro to Ethereum
  5. ethereum.org, The history of Ethereum (Yellow Paper, Fusaka)
  6. Etherscan, WETH9 contract, deployed bytecode (read on 19 November 2026)
  7. Etherscan, Ethereum block 26,449,058 (read on 19 November 2026)

Read next.