[EVM: Zero to Hero] Starting at zero...
Explaining what powers the worlds most valuable blockchains
Welcome back to Coinsights!
We’re excited to launch the highly requested series EVM: Zero to Hero. In this series, we’ll start with the basics and work up to the theories underpinning the Ethereum Virtual Machine (EVM). If you’re ready to learn about what powers the world’s most valuable blockchains, this is the series for you. Let’s get started!
Before the EVM, blockchains could only transfer cryptocurrency from one account to another. This was good for one-off payments, but not much else.
However, the creators of the EVM saw a future where the blockchain could run programs that executed complex logic and stored relevant data. Think going from a single stream soda dispenser to mixing to your heart’s content on the CocaCola Freestyle: a complete game changer.
The EVM defines a protocol for how programs, called smart contracts, run on blockchains. Smart contracts are important because they provide a layer of customizability to the blockchain. They are the tools that developers use to create products directly on the blockchain, from games to new ways to power the economy.
Many popular blockchains already use the EVM, including Polygon, Avalanche, Optimism, and of course Ethereum. In fact, I think the EVM will become as well-known as other key internet protocols like HTTPS and SSL. This belief is exactly why the series exists!
In order to truly appreciate the EVM, we first need to cover a few basics.
Basics 1: Building a Blockchain
A transaction specifies a change to be made from one state to another.
Transactions are grouped into blocks. Blocks are then chained together, forming a blockchain.
Blocks depend on the previous state, which is determined by the previous block, and so on. Therefore, the blockchain is a sequential list of changes (blocks) made to an implicit state. In order to calculate the current state of a blockchain, you need to consider every block starting with the genesis (first) block. A more technical guide to how this works is here.
Basics 2: Creating Trust
One of web3’s founding principles is to increase trust in the systems we use.
First, consider a centralized system. In this case, a single entity has complete control over the state of the system. If someone were to ask this entity what the state was, the entity could respond with anything they wanted. This comes with downsides:
Every institution that distributes power, money or status eventually falls to bias and corruption. Centralized internet platforms are no exception. It's fundamentally self-interested human behavior playing out at scale: a feature, not a bug.
In a decentralized system, the state of the system is determined by a collection of nodes that come to consensus over the correct state of the blockchain. If someone asks for the state, the response is whatever the majority of nodes believe to be correct.
A decentralized system shifts power away from a single entity and ensures a few bad actors can’t compromise the integrity of an entire system. This increases the trust that users have in the system.
The EVM
I mentioned earlier that smart contracts are powerful because they enable developers to create complex applications on the blockchain:
Smart contract applications include financial purposes, gaming, healthcare, and real estate; and they can even be used to configure entire corporate structures.
However, we haven’t covered how a smart contract actually runs on the blockchain. Enter the EVM.
The Ethereum Virtual Machine is the runtime environment for smart contracts in Ethereum.
In plain language, smart contracts are called by a transaction. The EVM helps nodes determine the output of a smart contract. This output represents a state change, and the EVM “tells” the node this output so that the node can update its state.
Here’s a step by step breakdown of this all works:
A user sends a transaction to a node, telling the node which smart contract they want to use
The node calls the EVM with the details of the smart contract to be run
The EVM runs the smart contract code, determining the changes to be made
The EVM updates the state on the node based on determined changes
The node places the current transaction into a block and broadcasts the block to the other nodes
If a majority of the nodes agree (they use the EVM to check!), then the block is added to every node’s copy of the blockchain
All nodes now have the same state as the original node
If you’re math-inclined, the specification for how the EVM works is defined in the Ethereum Yellow Paper. However, at this point the implementation details of the EVM don’t really matter.
What matters is that nodes are running an EVM that is compatible with everybody else’s EVM. Two nodes running the same smart contract at the same time should get the same output. The deterministic nature of the EVM is what makes the underlying consensus work!
EVM Compatibility
It’s difficult to make a one-size-fits-all solution for any problem. Blockchains are no different, and many are built with specific use cases in mind. However, it would be a waste of time for developers to constantly rewrite their smart contracts for every new blockchain that was introduced. To fix this, many blockchains are designed to be EVM Compatible.
A blockchain protocol is EVM Compatible if its smart contracts can run on the Ethereum Virtual Machine.
The EVM enables developers to write blockchain-agnostic smart contracts, which ultimately increases the productivity of the entire web3 ecosystem.
For example, Polygon is a popular blockchain that launched as an alternative to Ethereum. Compared to Ethereum, Polygon can handle ~1000x more transactions per second at a fraction of the cost. These stats make using Polygon and Ethereum feel very different. Nevertheless, there is one key similarity: both are EVM compatible.
One of the main reasons for Polygon’s meteoric rise is because it is EVM compatible. Paired with minuscule transaction fees, Polygon is an attractive alternative to Ethereum as it takes minimal effort for developers to port over their smart contracts.
Recap
Enjoyed this article? The next article in this series is out now!
In today’s article, we covered:
Blockchain fundamentals: transactions and decentralized systems
How the EVM helps with running transactions
Why EVM compatibility standardizes the developer experience across blockchains
This is just the start of the series EVM: Zero to Hero. I’d love to hear what you think and the future topics you’d like to see! Simply comment below or reach out on Twitter.
Thank you to Kristen, Eric, and Cece for their contributions to this article.