The EVM is often described as a "World Computer." It is a quasi-Turing-complete state machine that exists on thousands of nodes simultaneously. "Quasi" is a critical distinction: unlike your laptop, EVM execution is bounded by Gas to prevent infinite loops (The Halting Problem).
Y(S, T) = S'
Given an existing State (S) and a new Transaction (T), the Ethereum State Transition Function (Y) produces a new State (S'). This transition is deterministic; every node in the world must agree on the exact result S'.
When a smart contract executes, it has access to three distinct types of data storage. Understanding the cost difference between them is vital for optimization.
Last-in, First-out (LIFO) container for up to 1024 256-bit values. Most opcodes (ADD, SUB) work directly here. It is wiped after execution.
Linear, expandable byte array. Used for complex structures like strings or arrays during execution. It scales quadratically in cost and is wiped after execution.
A massive Merkle-Patricia Trie that persists on the blockchain. Writing here (SSTORE) is the most expensive operation (20k+ gas) because every node must store it forever.
The EVM does not understand Solidity. It understands Bytecode.
When you compile a contract, it turns into a string of hex bytes (e.g., 0x60806040...). During execution, the EVM reads these bytes one by one as Opcodes.
Gas is not just a fee; it is a unit of computational effort. It decouples the market price of ETH from the cost of computing.
Without gas, a malicious user could deploy a contract that loops forever while(true) {}. If validators ran this, the entire network would freeze.
Every instruction implies a cost. The sender prepays a "Gas Limit." The EVM deducts gas as it runs opcodes. If the counter hits zero, Out of Gas triggers, and the transaction reverts immediately.
The EVM standard has become the de-facto operating system of Web3. "EVM Equivalence" means a chain can run Ethereum smart contracts without modification.
No. You compile to Bytecode. The EVM interprets this bytecode. It acts as a virtualization layer between your smart contract and the actual server hardware.
Yes. This is called a 'Message Call'. Contract A can call Contract B. However, Contract A must pay the gas for Contract B's execution.
The 'World State' is stored in a Merkle-Patricia Trie structure. The root hash of this trie is included in every block header, ensuring cryptographic proof of the entire network's data integrity.