What Is Ethereum Virtual Machine (EVM)?
Ethereum Virtual Machine (EVM) is a software that sets the rules of computing the state of the Ethereum network from block to block. The EVM is a core part of Ethereum as it executes smart contracts, processes transactions, and updates account balances.
In simple words, EVM is a virtual machine or a cloud computer that powers the Ethereum protocol. Just like a computer, it executes code and has memory to save information. However, EVM is not just a single computer but a pool of thousands of cloud machines around the world.
EVM’s Key Functions
Managing the state of the Ethereum blockchain
Executing smart contracts
Calculating gas fees
How Does the EVM Work?
Developers on Ethereum write their smart contract code in a programming language called Solidity. The code is then translated to byte code so that the EVM can read the instructions.
In the process of translating the code from Solidity to byte code, the instructions are first broken down into ‘opcodes’ or operation codes. Every line of code is converted to opcodes so that the EVM knows exactly how to execute a transaction.
As we know, every transaction on Ethereum requires a gas fee to be executed. Therefore, the relationship between opcodes and gas fees is also important in understanding how the EVM works.
In theory, when you are paying gas fees, you are actually paying for the opcodes to be executed by the EVM. The more opcodes there are, the higher your gas fees will be.
EVM’s Key Features
- Turing-complete virtual machine
The EVM is designed as a Turing-complete virtual machine. Turing completeness refers to a machine that can solve any problem if it is given the necessary resources of time, energy, and complete instructions.
Ethereum’s Turing completeness is the network’s ability to understand and implement future agreements of a smart contract.
- Deterministic code execution
The EVM executes code deterministically. A particular smart contract will always produce the same output for the same input. It does not matter where the smart contract is executed or who is executing it, the output will always be consistent for a particular input.
The EVM is designed to work in isolation from the rest of the computer system. This ensures that the smart contracts are executed within a safe environment.
EVM code: The byte code that the EVM can execute.
State: Ethereum is a large data structure that holds information on accounts and balances. The state of this information changes from block to block as the EVM processes new inputs to produce deterministic outputs.
Transactions: Transactions are cryptographically-signed instructions from users that the EVM executes. There are two types of instructions:
- Message calls can be simple transaction instructions for sending ETH from one account to another.
- Contract creation is instructions to create new smart contracts.
Space: The EVM utilizes three space components:
- Stack – temporary storage that has a maximum capacity of 1024 items. All operations are performed on the stack.
- Memory – temporary storage that is only accessible during smart contract execution. Its contents are discarded once contract execution is complete.
- Storage – persistent memory that does not get lost as the data is stored on the Ethereum blockchain. Compared to stack and memory, the use of storage memory results in higher gas fees.
Gas: The amount of computational effort required to execute operations on a blockchain network. Every EVM computation requires gas fees otherwise, the transaction will not be processed.
Importance of EVM-Compatibility
Ethereum has grown to become the most valuable smart contracts public blockchain network in the world.
On June 21, 2023, Ethereum’s ecosystem of decentralized applications (dApps) boasted a total value locked (TVL) of $24.63 billion. The second most-valuable chain Tron held a TVL of $5 billion, according to DefiLlama. This shows a clear market preference for Ethereum, which has established itself as the go-to blockchain for decentralized finance (DeFi).
Numerous blockchain networks are designed to be EVM-compatible. This allows the blockchain to execute Ethereum smart contracts. EVM compatibility enables developers to easily deploy their smart contracts across Ethereum and multiple EVM-compatible chains.
EVM-compatible networks can tap into the vast pool of Ethereum users, which can be critical for growth and mass adoption.
Which Chains Are EVM-Compatible?
- BNB Chain
- Polygon PoS
The EVM software is the lifeblood of Ethereum as it maintains the state of the blockchain and executes smart contracts.
The meteoric growth of Ethereum has made EVM an industry standard, so much so that rival blockchain networks are designing their systems to be compatible with it.