[ 08 / 16 ] · Monad Track

Lesson 08: How Does the EVM Actually Work?

9 minutes200 XP

Embark on your journey to building production grade apps.

You've deployed a smart contract to Monad. You've watched a transaction get confirmed. But what actually happened in between? This lesson opens the hood.


In the last lesson, you shipped a dapp to Monad — the contract went on-chain, the transaction got confirmed, and the state changed for everyone. But something has to actually run that smart contract code the same way on every node in the network. That something is the EVM.

The EVM is the reason your smart contract does exactly what you told it to do, every time, on every computer in the network, without anyone coordinating it. Understanding what it is - even at a high level - will make you a better builder.


What is the EVM?

EVM stands for Ethereum Virtual Machine. It's the engine that executes smart contract code on Ethereum-compatible blockchains - including Monad.

When you deploy a smart contract, you're not putting human-readable code onto the blockchain. You're putting a set of extremely simple instructions that the EVM knows how to execute. Every node in the network runs the same EVM, executes the same instructions, and arrives at the same result. That's how the network stays in agreement without a central server telling everyone what to do.

Think of the EVM as a calculator that the entire network shares. When a transaction comes in, every node runs the same calculation. If they all get the same answer, the transaction is valid. If even one result is different, something has gone wrong.

What does the EVM do?


Ethereum is a State Machine

To understand the EVM, it helps to understand what kind of system Ethereum actually is.

Ethereum is a state machine. That means it has a current state - a snapshot of all accounts, all balances, and all data stored in every smart contract - and it moves from one state to the next every time a new block is processed.

A simple analogy: think of a scoreboard at a basketball game. The scoreboard has a current state (the score). Every time a basket is made, the state changes. The rules of basketball define exactly how the state is allowed to change - you can't just put any number on the board.

Ethereum works the same way. The current state is everything happening on the network right now. Every transaction is like a basket - it changes the state according to rules. The EVM is what enforces those rules and computes the new state.

This is why Ethereum is often called a distributed state machine rather than just a distributed ledger. Bitcoin is mostly a ledger - it tracks who sent what to whom. Ethereum tracks the full state of every smart contract on the network.

What is Ethereum's 'state'?

What makes Ethereum different from Bitcoin as a system?


What Happens When Your Contract Runs

When someone interacts with your smart contract - say, clicking "Update Message" in your app - here's what actually happens:

  1. A transaction is created. Your wallet signs a transaction that says "call this function on this contract with these inputs."

  2. The transaction is broadcast to the network. Every node receives it.

  3. The EVM executes the contract code. Every node runs the same instructions against the current state. No node is trusted more than any other - they all have to arrive at the same result independently.

  4. The state updates. If the transaction is valid, the new state - including whatever your contract stored - is recorded on the blockchain.

  5. The block is finalized. The new state becomes the official state of the network.

The key insight: no single computer is running your contract. Thousands of computers are running it simultaneously and checking each other's work. That's what makes it trustless.

Why does every node execute the same smart contract code?


From Solidity to Opcodes

When you write a smart contract (or your AI agent writes one), it's written in Solidity - a human-readable language. But the blockchain doesn't understand Solidity. Before your contract can run, it gets compiled into something the EVM does understand: opcodes.

Opcodes are extremely simple instructions. Things like ADD, SUB, MUL, DIV - basic math. STORE, LOAD - read and write data. Each opcode does exactly one thing. Your entire smart contract, no matter how complex, boils down to a long sequence of these tiny operations.

This is the same idea as how your laptop works. You write code in Python or JavaScript. The computer doesn't understand those languages directly - it compiles them down to low-level instructions the CPU can execute. Opcodes are the EVM's version of those low-level instructions.

You never see the opcodes. Your agent writes Solidity, Hardhat compiles it, and the EVM runs the result. But this is what's happening under the hood every time your contract executes.

What are opcodes?


How the EVM Remembers Things

The EVM has two types of memory, and understanding the difference matters for how smart contracts work.

Memory is temporary. It only exists during a single transaction. The moment the transaction finishes, it's wiped. Think of it like a scratch pad - you can write things down while you're working, but it gets thrown away when you're done.

Storage is permanent. It lives on the blockchain and persists between transactions. When your MessageBoard contract saves a new message, that goes into storage. It's still there the next time someone calls the contract, the next day, the next year.

Storage is what makes smart contracts actually useful as backends. Any data your contract needs to remember - balances, ownership, messages, votes - gets written to storage, where it lives permanently on the blockchain.

This is also why interacting with storage costs more gas than using memory. Writing permanent data to thousands of nodes around the world is expensive. Temporary scratch pad math is cheap.

What is the difference between EVM memory and storage?


State Transitions

Every time a transaction runs, the EVM takes the current state of the network, applies the transaction, and produces a new state. This is called a state transition.

The important thing about state transitions is that they are deterministic - meaning the same input always produces the same output. If you give the EVM the same current state and the same transaction, it will always arrive at exactly the same new state, every time, on every node. No randomness. No ambiguity.

This is what makes the network trustless. Every node independently runs the same state transition and checks that it gets the same result as everyone else. If a node tried to cheat - to produce a different outcome - every other node would immediately reject it.

What does 'deterministic' mean in the context of the EVM?


Why Monad Runs the EVM

Monad is EVM-compatible. That means it runs the same EVM that Ethereum runs. Every smart contract that works on Ethereum works on Monad without any changes.

This is a big deal for builders. It means:

  • Everything you've learned about Solidity applies on Monad
  • Every tool you used (Hardhat, wagmi, RainbowKit) works on Monad
  • Smart contracts deployed on Ethereum can be redeployed on Monad with zero changes

The difference is that Monad runs the EVM significantly faster. Ethereum can process roughly 15-30 transactions per second. Monad is designed to handle thousands. Same rules, much higher throughput. That's the core of what Monad's architecture - pipelining, parallel execution, and MonadDB - is built to achieve.

So when you deployed your MessageBoard contract to Monad, you weren't using a different system. You were using the same EVM, just running on much faster rails.

What does EVM-compatible mean?


The EVM as a Shared Computer

Here's one more way to think about it.

Your laptop has a CPU - a chip that runs instructions. When you open an app, the CPU executes the code for that app. The EVM is essentially a virtual CPU that the entire Ethereum network shares.

Instead of running on a chip inside your machine, it runs on thousands of machines simultaneously. Instead of being controlled by one operating system, it's governed by the rules of the protocol itself. And instead of being used to run your apps locally, it's used to run smart contracts that anyone in the world can interact with.

This is why it's called a virtual machine. It behaves like a computer - it executes instructions, reads and writes memory, and produces outputs - but it doesn't exist on any single physical device. It exists across the entire network.

Why is the EVM called a 'virtual' machine?


What This Means for You as a Builder

Knowing what the EVM is changes how you think about what you're building. When you deploy a contract:

  • You're not renting a server - you're publishing code to a shared computer that thousands of nodes run
  • You're not trusting a company to execute your logic - the network enforces it
  • You're not storing data in a database someone else owns - the state lives on a decentralized machine

That's the foundation everything else is built on. Smart contracts work the way they do because the EVM works the way it does.

A Loud Caution About Vibecoding Smart Contracts

You already vibecoded a smart contract in the freshman track, and you'll write more as you move through the rest of the curriculum. Before you do, you need to understand something important: smart contracts are not like frontend code.

When you vibecode a UI and something breaks, you fix it and redeploy. The cost of a mistake is low. Smart contracts are different in a few critical ways:

  • Mistakes can be permanent. Smart contracts are immutable once deployed. If there's a bug in the logic, you often can't patch it - the flawed code is there forever.
  • Mistakes can be costly. Smart contracts can hold real money. A logic error in a contract handling funds can result in those funds being lost or stolen. This has happened many times to experienced developers - not just beginners.
  • AI models are less reliable here. Models are trained on far more frontend code than Solidity. They make more mistakes with smart contracts, and those mistakes are harder to spot.
  • Context gets complex fast. The moment your contract interacts with other protocols, the agent can lose track of important details that lead to subtle but serious bugs.

The message board contract from the freshman dapp lesson is intentionally simple - no financial logic. That's by design. For learning purposes, small and simple is always safer.

The rule of thumb: never deploy a smart contract that holds real funds without having it audited by an experienced Solidity developer. Vibecoding is a powerful way to learn and prototype. It is not a substitute for professional review when real money is on the line.


What's Next

Now that you understand what runs your smart contract, the next lesson is Monskills — how to turn a generic AI coding assistant into a Monad specialist that knows your stack, addresses, and deploy flow instead of guessing.

0/9 correct

0% — get all correct to complete

Sign Up to Track Progress