The Ethereum virtual machine, usually shortened to EVM, is the shared computer that every Ethereum node runs to execute smart contracts. It is not a physical machine but a precise set of rules that turns contract code and transaction data into identical results on thousands of computers.
Most people never see the EVM directly, yet it decides what applications can do, how much they cost to use and where many of their security problems come from. This guide explains how it works in plain terms and why its design matters to anyone holding or using assets on Ethereum.
A Computer That Thousands of Strangers Share
An ordinary computer runs programs for one owner. The EVM runs programs for everyone at once, and every full node repeats the same calculation to check the result. If one node reported a different outcome, the others would reject its version and keep the agreed state.
That arrangement needs a strict definition of every step. The EVM specification states exactly what each instruction does and what it costs, so a node written in Go and another written in Rust reach the same answer. The rules were first set out in Ethereum’s technical “Yellow Paper”.
The trade-off is efficiency. Repeating every calculation across the whole network is far slower and more expensive than running it on a single server. The EVM is therefore designed for tasks where trust and transparency matter more than speed, such as holding funds under clear rules.
Keeping this in mind helps set expectations. Applications on Ethereum keep heavy computation off-chain and use the EVM for the critical steps: moving value, recording ownership and enforcing agreements that participants want to verify for themselves.
From Source Code to Bytecode
Developers rarely write instructions for the EVM by hand. They write contracts in a high-level language, most commonly Solidity, which resembles JavaScript, or Vyper, which is modelled on Python. A compiler then translates that source code into bytecode, the compact numeric instructions the EVM reads.
The journey from idea to running contract usually follows these steps:
- Write the contract logic in Solidity or Vyper.
- Compile it into bytecode plus an ABI, a description of the functions other programs can call.
- Test it on a local simulated chain and on a public testnet, which uses valueless ETH.
- Deploy it by sending a transaction that contains the bytecode, creating a new contract account.
- Verify the source code on a block explorer so others can match it to the deployed bytecode.
Once deployed, the bytecode at an address cannot be edited. Projects that need changes often use upgradeable proxy patterns, where a small contract forwards calls to replaceable logic. That flexibility introduces a trust question: whoever controls the upgrade can change the rules.
Opcodes, the Stack and Gas
Bytecode is made of opcodes, single instructions such as add two numbers, compare values, read storage or send ETH. The EVM is a stack machine, which means it works by pushing values onto a pile and taking the top items off to operate on them, one instruction at a time.
Each opcode has a gas cost. Gas is the unit that measures computational work. Simple arithmetic costs very little gas, while writing new data to permanent storage costs much more, because every node must keep that data indefinitely. The total gas used determines the fee.
Every transaction sets a gas limit, the maximum it is willing to consume. If execution reaches that limit before finishing, the EVM stops and reverts all changes made by the transaction. The sender still pays for all the gas up to the limit, because nodes performed that work before the halt.
Gas pricing is how the EVM protects itself. Without it, someone could deploy a contract that loops forever and stall every node. Gas also gives developers a strong incentive to write efficient code, since lower gas use means cheaper interactions for their users.
Where the EVM Keeps Data
The EVM has several places to hold information during and after execution. Each has different costs and lifetimes, and understanding them explains why some actions are cheap while others are surprisingly expensive.
Storage
Storage is a contract’s permanent memory on the chain. Token balances, ownership records and settings live here. Writing to storage is among the most expensive operations, because the data becomes part of the state that every full node must keep and check from then on.
This is why applications try to store as little as possible on-chain, often keeping large files elsewhere and recording only a short reference or hash in contract storage.
Memory and the Stack
Memory is temporary scratch space that exists only while a transaction is running and disappears when it ends. The stack holds the immediate values used by opcodes. Both are much cheaper than storage, though memory costs grow as a transaction uses more of it.
The stack holds at most 1,024 values and code can reach only the top 16 directly, which limits how many variables one function can juggle. A separate cap on deployed code size is one reason developers split large systems into several contracts.
Calldata, Logs and Blobs
Calldata is the input attached to a transaction, such as the function being called and its arguments. Logs are event records that outside apps can track cheaply; contracts cannot read them back. Blobs, added in March 2024, carry rollup data outside the EVM: contracts see only a commitment hash, and nodes prune blobs after roughly 18 days.
Contract Accounts and Message Calls
When bytecode is deployed, it becomes a contract account with its own address, balance and storage. Unlike an externally owned account, which is controlled by a private key, a contract account cannot start a transaction by itself. It only runs when something calls it.
A single transaction can trigger a chain of calls. A user might call a trading contract, which calls a token contract to move funds, which in turn notifies another contract. The EVM tracks each step, and if any call fails without being handled, the whole transaction can revert.
Contracts can also create other contracts, which is how many applications deploy new markets or vaults on demand. Each new contract gets a predictable address derived from its creator, a property developers use to plan interactions in advance.
Since the Pectra upgrade in May 2025, EIP-7702 lets an externally owned account point to smart-contract code. This blurs the old line between the two account types and enables wallet features such as batching several actions into one transaction, though users should only approve delegation to code they trust.
What EVM Compatibility Means
The EVM has become a common standard well beyond Ethereum itself. Many rollups and several separate blockchains describe themselves as EVM-compatible or EVM-equivalent, meaning they can run the same bytecode, accept the same address format and work with the same wallets and developer tools.
For users, compatibility brings convenience. The same wallet can connect to several networks, and a familiar application may appear on many of them. For developers, it means existing contracts and audits can be reused with fewer changes, which lowers the cost of launching elsewhere.
Compatibility does not mean equal security. A network can run EVM bytecode while relying on a much smaller validator set, a single sequencer or a trusted bridge. The code behaves the same, but the guarantees protecting your assets may be very different from Ethereum layer 1.
When you see a token or app on an EVM-compatible network, check which chain you are actually on before signing anything. Sending assets to the right address on the wrong network is a common and sometimes unrecoverable mistake.
Limits and Security Lessons
The EVM executes code exactly as written, including mistakes. It has no notion of what a developer meant to do. Many losses in decentralized finance came from contracts that behaved precisely according to their code while doing something the authors never intended.
Several classes of weakness are widely documented:
- Reentrancy: a contract calls an outside address before updating its own records, letting that address call back in unexpectedly.
- Access-control bugs: sensitive functions such as minting or upgrading are left callable by the wrong people.
- Oracle manipulation: a contract trusts a price source that can be distorted for a short period.
- Arithmetic and logic errors: rounding or ordering mistakes that leak value over many transactions.
Independent audits, extensive testing and formal verification reduce these risks but cannot remove them. An audit report describes what reviewers checked at one point in time; later code changes or unusual market conditions can expose problems the review never covered.
Questions to Ask Before Trusting a Contract
Because the EVM enforces code rather than intentions, the useful question is not whether an app runs on Ethereum but what its contracts actually allow. A few checks help, even for readers who never plan to write code themselves.
Look for verified source code on a block explorer, published audit reports from more than one firm, and clear documentation of admin powers. Note whether contracts can be upgraded, who holds the upgrade keys, and whether there is a time delay before changes take effect.
Review the permissions your wallet grants. Approving a contract to spend your tokens lets its code move them later, sometimes without limit. Periodically revoking approvals you no longer need is a simple habit that limits damage if a contract is later compromised.
The EVM itself keeps evolving through network upgrades, and proposals to refine its instruction set continue to be debated. Following those discussions at a high level helps you understand how future changes might affect the applications and assets you depend on.