EVM Ethereum Virtual Machine cover — smart contract flow from Solidity code to compiled bytecode, running on the EVM stack machine with gas metering, dark tech infographic
Crypto Basics • • • Author:CoinVado Research • 10 reads • 11 min

How Smart Contracts Actually Run: The EVM, Solidity Compilation and Gas Metering Explained

What is the EVM, and why do smart contracts run identically across the whole network — yet stay expensive and slow? This guide unpacks the Ethereum Virtual Machine (a 256-bit stack machine), how Solidity compiles into bytecode, and why gas exists — not as a 'fee' but as a metering mechanism that solves the halting problem. Includes 2026 status and EIP-1559.

Table of Contents

TL;DR: The Bottom Line

Smart contracts run identically and immutably across the whole network thanks to three things: a virtual machine called the EVM (a 256-bit stack machine), a compiled language called Solidity, and a metering mechanism called gas.

Four key facts:

  1. Ethereum's essence isn't a "blockchain," it's a "world computer." The blockchain is just its ledger; the EVM is the core — it's what lets "code" be executed consistently by thousands of nodes, just like money is settled1.
  2. Solidity code doesn't go on-chain directly. It's first compiled into EVM bytecode (machine instructions), and only that bytecode is written to the chain — the chain stores "machine code," not your source2.
  3. Gas isn't a "fee" — it solves the halting problem. The EVM is Turing-complete, so you can't predict whether code will loop forever; without metering, one infinite loop could stall the whole network. Every operation is priced in gas, and when gas runs out, execution halts and reverts13.
  4. A smart contract isn't "run once" — it's re-run by tens of thousands of nodes. That redundancy is exactly why it's expensive and slow, and also why it's immutable1.

⚠️ This article explains the underlying technical mechanism of "how smart contracts run" — not investment advice, and not a Solidity programming tutorial. Understanding the EVM, compilation, and gas is the homework you should do before you can truly understand Ethereum (and every EVM-compatible chain).

If you just want to know "what Ethereum is and what smart contracts can do," start with the beginner's guide to Ethereum and smart contracts, then come back for this deeper breakdown.

First, Fix a Misconception: Ethereum Is a "World Computer," Not Just a "Blockchain"

Most people picture Ethereum as "a faster version of Bitcoin" or "a more advanced blockchain." That mental model misses the most important part.

Ethereum's real identity is a "globally shared computer."

Split "Ethereum" into two halves and the difference becomes clear:

  • The ledger half (the blockchain): records who sent how much ETH to whom, just like Bitcoin — this is the familiar part.
  • The compute half (the EVM): a virtual machine that can run arbitrary programs; anyone deploys code to it, and that code gets executed consistently by the whole network — this is what sets Ethereum apart from Bitcoin.

Bitcoin's ledger can only do one thing: accounting. Ethereum layers a general-purpose compute engine on top of the ledger. When you borrow in DeFi, trade in an NFT marketplace, or swap on a DEX, none of that is a "transfer" — it's "calling a piece of code deployed on the EVM."

Remember it this way: the EVM is to Ethereum what the CPU is to a computer. Without the EVM, Ethereum would be just another "blockchain with a token"; with it, "code" becomes a public, trustless utility for the first time1.

With that understood, the next three mechanisms fall into place — starting with what this "CPU" actually looks like.

The EVM, Unpacked: A 256-Bit Stack Machine

The EVM isn't a physical server — it's a specification that defines "how a transaction should be computed." As long as your node follows that spec and arrives at the same result as the rest of the network, you're "running an EVM."

Its key design choices1:

  1. 256-bit word size. Every basic operation works on 256-bit (32-byte) values — aligned with cryptographic operations like hashing and elliptic-curve signatures, and it lets a 20-byte Ethereum address fit comfortably in one "word."
  2. Stack-based execution. The EVM is a stack machine operating last-in-first-out (LIFO), with the stack limited to 1,024 elements. That bounds how much it can "take in one bite," and doubles as a boundary against unbounded nesting.
  3. Isolated sandbox. When the EVM runs code, it can't reach the network, filesystem, or other external resources — it can only read its own inputs and write the state it manages. That guarantees the same code produces the same result on any machine.
  4. Determinism. Same initial state + same transaction → the same result on every node, guaranteed. There's no randomness and no uncontrolled "current time" (time can only be read from the block timestamp). Because it's deterministic, the network can reach consensus on "what the world looks like after this code runs."

Put together, that's the EVM's portrait: a 256-bit, stack-based, sandboxed, deterministic, Turing-complete machine.

That word "Turing-complete" matters — it's both what makes the EVM powerful and the direct reason gas exists. Keep it in mind; we'll come back to it.

EVM Ethereum Virtual Machine diagram: a 256-bit stack machine where a transaction executes opcode by opcode with gas metering, producing a network-wide identical result, dark tech infographic

From Solidity to Bytecode: How Code Becomes an Executable Contract

The Solidity code you write never goes on-chain "as-is." It goes through a compilation step into the "machine code" the EVM can actually read2.

What Solidity is: Ethereum's primary smart-contract language — statically typed and contract-oriented, with syntax that resembles JavaScript but is stricter. The latest version is 0.8.35 (released 2026-04-29), stable on the 0.8.x line for over five years2. In September 2026, Vitalik also announced a Solidity compiler rewritten in Zig called oksolc, aiming to produce identical bytecode while dramatically speeding up compilation2.

What compilation does: the compiler (solc) translates your .sol source file into a string of EVM machine instructions (opcodes) — low-level instructions like PUSH1, ADD, STOP. That bytecode is what the EVM actually executes.

An easily-missed detail: what's stored on-chain is the compiled bytecode, not your source code. When you deploy, you send the bytecode to the chain and it's written permanently. That means:

  • Once deployed, a contract cannot be modified — unless you built in "upgrade logic" in advance (an advanced pattern like a proxy contract).
  • The hard-to-read "machine code" others see in a block explorer is what you actually deployed. Blockchain "immutability" concretely means "code is law, and deployment is final."

Solidity to EVM bytecode compilation flow: a .sol source file translated by the compiler into EVM bytecode, deployed on-chain and called during execution, dark tech infographic

That raises a natural question: if every operation is executed network-wide, where does that execution resource come from, and who pays for it? — The answer is gas.

Why Gas Exists: The Halting Problem and Metering

Many people assume gas is "Ethereum's toll booth," meant to make the project money. That's the deepest misconception. The real reason gas exists is a piece of mathematics called the halting problem13.

What the halting problem is: given a program, is there a general algorithm that can decide in advance whether it "will stop"? Computer science's answer is no. For an arbitrary program, you cannot determine before running it whether it will fall into an infinite loop.

On Ethereum, the problem becomes severe: the EVM is Turing-complete, so it can theoretically run any computation — but Turing-completeness means malicious code can be written as an infinite loop. If execution weren't metered and capped, a single infinite loop could make every node compute forever, paralyzing the entire chain.

Gas is the "fuel gauge" designed for exactly this problem13:

  1. Every basic operation is priced. From simple arithmetic to storage reads/writes, every opcode has a fixed gas cost — an ordinary ETH transfer, for example, has a base cost of 21,000 gas.
  2. The caller sets a cap. When you send a transaction, you specify the maximum gas you're willing to burn (the gas limit) and how much you'll pay per unit (the gas price).
  3. When it runs out, it stops and reverts. If execution hits the gas limit before finishing, the machine immediately halts the transaction and reverts state to the starting point — but the gas already burned is not refunded (the penalty for initiating a computation that didn't complete).

So gas buys "network-wide repeated execution of this computation" — it's not a toll for anyone. Infinite loops can't drag down Ethereum not because someone blocks them, but because they'll eventually burn through their gas and be force-stopped.

After EIP-1559, the fee structure got smarter (London upgrade, 2021-08-05)3: gas fees split into two parts — a base fee priced algorithmically by the protocol based on congestion, fluctuating block to block and burned; and a priority fee (tip) paid to validators to prioritize your transaction. This design also gave ETH a "burn" mechanism: since launch in 2021, roughly 4.5 million ETH has been permanently burned3.

Why It's Expensive and Slow: The Cost of Deterministic Execution

With the EVM, compilation, and gas in hand, we can answer the most common complaint: "Why is Ethereum so expensive and slow?"

The one-sentence answer: every transaction is re-executed across the whole network to buy the certainty that no single party can cheat1.

  • Place an order on Binance and only Binance's servers compute it — fast and cheap, but you have to trust Binance.
  • Call a contract on Ethereum and thousands of nodes each independently re-run the same code, then vote to reach consensus on the result. Slow and expensive, but no single party can tamper with the outcome.

That "redundant execution" is exactly the source of its security, and also the price of its cost and speed. The fundamental difference between a "world computer" and AWS is this: one pays a redundancy cost for trustlessness, the other sacrifices decentralization for efficiency.

The good news is that cost has fallen dramatically by 2026. Mainnet gas is extremely low right now — a standard rate around 0.15 gwei means an ordinary transfer costs under $0.01, because roughly 95% of transactions have moved to Layer 2, and L1 blocks are only about 62% full on average3. Layer 2's idea is "move most computation off-chain, submit only compressed data or a proof back to the mainnet for settlement," cutting costs by another 90%+. To understand how L2 pulls that off, see the Ethereum Layer 2 comparison: Arbitrum, Base, Optimism.

Three Things This Means for You

Tying the mechanisms together, it comes down to three things for you:

  1. "Code is law" is a double-edged sword. A contract can't be modified once deployed — that's both why DeFi can run trustlessly and why a single bug can stay on-chain forever (the 2016 The DAO hack, which drained 3.6M ETH, is the lesson). Before using any DApp, check whether it's been audited.
  2. Understand gas so you don't overpay. Gas is the cost you pay for "network-wide repeated execution," not a fixed rate — expensive when congested, cheap when idle. For how to save, see the Gwei guide: Ethereum gas fee explained.
  3. A "world computer" is not a "fast computer." Don't compare Ethereum mainnet to centralized servers on speed — they solve different problems. For low-cost, high-frequency operations, use Layer 2 or a high-performance chain; use the mainnet only when you need the strongest decentralization guarantee.

💡 Once you understand the mechanics, actually interacting on-chain (transfers, DApps, buying crypto) requires an exchange account. If you don't have one yet, you can register for Binance (code BINANBT) or register for OKX (code 60895497) and enjoy a 20% trading-fee rebate.

FAQ

What is the EVM, and how does it relate to Ethereum?

The EVM (Ethereum Virtual Machine) is the runtime environment that executes smart contracts — the CPU of Ethereum's "world computer." It's a 256-bit stack machine that runs in isolation and produces deterministic results. Every node runs the same EVM, and all must arrive at the exact same result for the same transactions, or consensus breaks. Ethereum = a ledger (the blockchain) + a compute engine (the EVM); the latter is what separates it from Bitcoin.

What is a smart contract, and why is it "a program running on-chain"?

A smart contract is code deployed to a blockchain that executes automatically when its conditions are met, with no intermediary approving anything. "Running on-chain" means the code is compiled to EVM bytecode, written permanently to the chain, and then re-executed by thousands of nodes every time it's called, with the result confirmed by consensus. Because "everyone runs it," it can't be altered or unilaterally stopped — but that's also why it's expensive and slow.

What is Solidity, and how does code actually get on-chain?

Solidity is Ethereum's primary smart-contract language — statically typed and contract-oriented, latest version 0.8.35 (released 2026-04-29). Your .sol source file never goes on-chain directly: the compiler first translates it into EVM bytecode (machine instructions), and only that bytecode is written to the chain at deployment. The chain stores "machine code," not your source — which is why a contract can't be modified once deployed (unless you built in upgrade logic).

Why does gas exist? What is it actually charging for?

Gas is not fundamentally a transaction fee — it's a metering mechanism that solves the halting problem. The EVM is Turing-complete, meaning you can't predict whether code will loop forever; without metering, one infinite loop could stall the whole network. So every opcode is assigned a gas cost, callers set a limit, and when gas runs out execution halts and reverts. The gas you pay buys the network-wide repeated execution of this computation.

How is gas calculated after EIP-1559?

Since the London upgrade on 2021-08-05, gas fees split into two parts: the base fee, priced algorithmically based on congestion, fluctuating block to block and burned; and the priority fee (tip), paid to validators to prioritize your transaction. In 2026 mainnet gas is extremely low — a standard rate around 0.15 gwei means an ordinary transfer costs under $0.01, because roughly 95% of transactions have moved to Layer 2.

Why is Ethereum mainnet expensive and slow, but Layer 2 cheap?

Because of deterministic execution — every transaction is re-run by thousands of nodes to reach consensus, and that redundancy is both the source of its security and the reason it's costly and slow. Layer 2 does most computation off-chain and only submits compressed data or a proof to the mainnet for final settlement, cutting costs by over 90%. This is the fundamental difference between a "world computer" and a centralized server like AWS.

Further Reading


Data verification note: EVM architecture (256-bit stack, 1,024 depth, isolated sandbox, deterministic, Turing-complete), Solidity version (0.8.35), the gas metering mechanism (halting problem, 21,000 gas, EIP-1559), and 2026 gas status (~0.15 gwei, 95% of transactions on L2, ~4.5M ETH burned) were verified on 2026-09-28; sources in the footnotes below123. On-chain metrics change in real time (especially gas rates and burn amounts) — check ethereum.org's official documentation and Etherscan for live figures before acting.

This article is not investment advice. Ethereum and crypto assets are highly volatile, and smart contracts carry code-bug and exploit risks. Make decisions carefully based on your own situation and comply with local laws and regulations.

Footnotes

  1. EVM architecture and execution model: the EVM is a 256-bit, stack-based (LIFO) execution machine with a stack limit of 1,024 elements; it runs in an isolated sandbox with no access to the network/filesystem; execution is deterministic (same state + transaction → same result), which enables consensus; the EVM is Turing-complete, so gas metering was introduced to solve the halting problem and prevent infinite-loop DoS. Sources: Mastering Ethereum (Chapter 14, The Ethereum Virtual Machine), ethereum.org EVM documentation (queried 2026-09). ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9

  2. Solidity and compilation: Solidity is a statically typed, contract-oriented language compiled to EVM bytecode before deployment (the chain stores bytecode, not source); latest version 0.8.35 (released 2026-04-29), stable on 0.8.x for years; in 2026-09 Vitalik announced a Zig-rewritten compiler oksolc targeting identical bytecode with faster compile times. Sources: Solidity official documentation and release history, ForesightNews/ChainCatcher reporting (queried 2026-09). ↩ ↩2 ↩3 ↩4 ↩5

  3. Gas and EIP-1559: each EVM opcode has a gas cost, an ordinary ETH transfer has a base cost of 21,000 gas, and execution halts and reverts when gas runs out; EIP-1559 (London, 2021-08-05) split fees into a base fee (protocol-priced, fluctuating, burned) plus a priority fee (validator tip); roughly 4.5M ETH burned since 2021. 2026 status: mainnet standard rate ~0.15 gwei (Etherscan, 2026-05-05), ordinary transfers <$0.01, ~95% of transactions on rollups, L1 blocks ~62% full on average. Sources: ethereum.org EIP-1559 documentation, Etherscan Gas Tracker, KuCoin/CoinLaw reporting (queried 2026-09). ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7

#what is EVM #Ethereum Virtual Machine #smart contract #Solidity #gas mechanism #EVM #Ethereum gas #bytecode #halting problem #world computer #EIP-1559 #crypto fundamentals

About the author

CoinVado Research

CoinVado Research

CoinVado Research is the digital asset research team of CoinVado, focusing on cryptocurrency education, blockchain technology普及, and Web3 ecosystem research.

Research directions
  • Cryptocurrency basics
  • Digital asset investment education
  • Blockchain technology and applications
  • Web3 ecosystem development
  • On-chain assets and wallet security

If you find errors or have suggestions, contact us via Telegram

Buying USDT / Sign-up / Withdrawals?

Join our Discord community for quick crypto help

Join Discord