The Ethereum Virtual Machine (EVM) is often called the World Computer. Today’s write-up explains why and exactly how the EVM works. Enjoy.
*Thank you to Ziad and Vero for proofreading.
Blockchains are the Records
Blockchains are excellent records of transactions. Each block contains a set of transactions that records changes on the blockchain, often to account balances; when I send money to you, the blockchain records how much more or less each of us has. The blockchain is the record, but what makes changes to it is known as a “state machine.”
State Machines Change Blockchains
A state machine updates the state of the blockchain from a previous to a new state. When I sent money to you, the blockchain included a record of that transaction, but the state machine is what wrote it there. In other words, the blockchain records transactions, whereas state machines execute them.
Single-Focus State Machine
Bitcoin was the first widely-used public blockchain. It’s state machine was responsible for very basic features, essentially executing transactions between people. It was hard to do anything with Bitcoin other than use it to send or receive funds; Bitcoin’s state machine could only execute transactions between people.
General Purpose State Machine
Ethereum was created to improve upon this model. The key changes Ethereum made were that the blockchain could store code, and the state machine could execute it. Ethereum’s state machine is what we know as the EVM, and is capable of executing transactions as well as code. Programs could be coded on the blockchain, taking advantage of their ability to handle money.
Programs on the Blockchain
Programs that are accessible through the blockchain have several benefits. They are censorship-resistant, meaning they cannot be destroyed or silenced. They are transparent, meaning people can see what each program is doing and who created it. They are trustless, meaning one can verify what the a program does instead of trusting it. They are accessible to all, meaning anyone with an internet connection has equal opportunity to access.
Turing-Complete
The Ethereum Virtual Machine is capable of executing any program or algorithm, given enough resources. In computer science terms this means it is a Turing-complete machine. Programs are written mainly in Solidity, which are then converted into “opcodes,” a lower level of instruction, which convert to hexadecimal bytes which the EVM actually executes.
EVM Executes Transactions
To better understand the EVM, we should quickly review what a transaction is on Ethereum. A transaction is a message with either funds, data, or both, between people and/or programs. People are known as Externally Owned Accounts (EOAs), and programs are called smart contracts. When a transaction is performed, the EVM looks at what it contains (funds, data, or both) and the type of address it’s going to (either a person or a program). A transaction to create a smart contract is the only type that does not have a “to” address.
Transactions Containing Data
When I send you money, that’s a transaction with funds but no data. When we interact with smart contracts on the other hand, things become more interesting. Transactions with smart contracts can include funds or data, or both. When funds are sent to a smart contract, it can hold them or perform actions with them. The types of actions performed by the smart contract depend on the data in the transaction.
Transaction Data Tells EVM What to Do
Smart contracts are programs, each often capable of doing multiple different things. The different things smart contracts can do are designated as functions, and the data included in a transaction determines which function is called. This enables multi-purpose smart contracts and programs with many layers and levels of flexibility.
The EVM Updates the Blockchain
To be more specific, when a transaction is sent the EVM looks at what it contains, then executes the smart contract’s code based on the data and/or funds inside. The result is recorded on the blockchain. The blockchain is the record, and the EVM is what causes changes to it.
The World’s Computer
Ethereum is the World Computer, accessible to all to use and build upon. Any program can be built on this new operating system, available to all, censorable by none. Ethereum decentralizes money as well as applications, and opens access to the world.
Thank You & Additional Reading!
I hope you enjoyed this write-up on the EVM! This will be important knowledge for upcoming write-ups on EOF, Transient Storage, Verkle Trees, and many more!
Here are some more resources if you'd like to dive deeper.
Mastering Ethereum by Andreas Antonopoulos and Dr. Gavin Wood, Chapter 1
Share a Summary
Thank you for reading, please consider sharing this newsletter below!
Stay kind. Stay curious.