Ethereum Virtual Machine (EVM) Explained: A Comprehensive Guide

·

Introduction to EVM

The Ethereum Virtual Machine (EVM) is a stack-based virtual machine designed for executing smart contracts on the Ethereum blockchain. With a maximum stack depth of 1024, each element is 256 bits (32 bytes) wide. During execution, it maintains transient memory (volatile storage) and processes operations via an instruction set where each opcode is 8 bits long.

Key Features of EVM:


EVM Bytecode and Instruction Set

Explore the full EVM opcode reference at ethervm.io. Below are categorized instructions:

1. Arithmetic and Logical Operations

Performed modulo 2²⁵⁶ unless specified otherwise.

| Opcode | Name | Input Stack | Output Stack | Description |
|--------|---------------|------------------|-----------------|--------------------------------------|
| 0x01 | ADD | a, b | a + b | Addition |
| 0x02 | MUL | a, b | a * b | Multiplication |
| 0x03 | SUB | a, b | a - b | Subtraction |
| 0x10 | LT | a, b | a < b | Unsigned comparison |
| 0x16 | AND | a, b | a & b | Bitwise AND |

👉 Master EVM opcodes with this interactive tool

2. Storage and Memory Operations

EVM uses three storage types:

| Opcode | Name | Function |
|--------|---------------|-------------------------------------------|
| 0x51 | MLOAD | Load 32 bytes from memory |
| 0x55 | SSTORE | Write to persistent storage |

3. Control Flow Instructions

4. Contract Interaction


EVM Reverse Engineering Tools

When source code is unavailable, use these resources to decompile bytecode:

  1. EtherVM Decompiler
  2. Dedaub Contract Library
  3. Etherscan Verified Contracts

👉 Explore advanced EVM analysis techniques


FAQs

Q1: What distinguishes EVM from traditional VMs?

A: EVM is purpose-built for blockchain, featuring deterministic execution, gas metering, and persistent storage.

Q2: How does DELEGATECALL differ from CALL?

A: DELEGATECALL runs the external code in the context of the caller’s state, whereas CALL modifies the callee’s state.

Q3: Can EVM handle floating-point operations?

A: No—all arithmetic is integer-based modulo 2²⁵⁶.


This guide covers EVM’s core mechanics, instruction set, and practical tools for developers. For further reading, consult Ethereum’s official documentation.

Last updated: November 2022