EVM not EVM network
11 minutes
AdvancedEVM - machine with many names
The World Computer. Unstoppable Machine. The Heart of Ethereum. The Ethereum Virtual Machine (EVM) has many names, underscoring its importance to the Ethereum network. It is the core function that makes it not just a "distributed ledger" like Bitcoin, but a "distributed computing network".
The EVM enables developers to create smart contracts in the Solidity programming language. A popular use of smart contracts is managing the creation and exchange of tokens. Many applications and protocols use tokens to incentivize users for actions that are important to their goal. Without the EVM, all of this would be impossible.
Virtual machines - EVM platform
If you've ever downloaded a movie, song, or program (legally, of course) using BitTorrent, then you understand the benefits of a decentralized network. Even if you are the most powerful authority in the world, taking down a decentralized network is difficult because it would require disconnecting every member of the network.
A good way to scale a decentralized network is to use virtual machines (VMs). This is because VMs can be run on different operating systems and hardware, and from any geographic location.
Virtual machines operate as a layer of abstraction between code and the machine executing the code. Virtual machines function similarly to a physical machine with storage, memory, and a processor, but they operate purely as an algorithm.
In theory, anyone can run a virtual machine, which makes it a highly portable platform for a distributed network. The EVM uses a decentralized network of nodes to execute smart contracts.
Smart contracts - EVM application
Smart contracts are self-executing lines of code that allow parties to transact with each other without the need for a third-party intermediary to ratify the transaction. A smart contract is a list of specific operations that are executed when certain conditions are met on or off the network.
Some of the operations can include transferring funds to a specific address, interacting with another contract, or even creating a new contract. Instead of a third party executing the transaction, any sender can send funds to the smart contract address to initiate these operations.
What makes smart contracts a secure method of transactions is the fact that the code cannot be discredited, hacked, or changed. There is always an expected outcome from the smart contract, which is the inherent trust in the code. It is said that every time the contract is executed, it changes the state of the EVM.
EVM can be described as a "state machine" because it is responsible for computing state changes that result from executing smart contract code. This means that EVM maintains the Ether balance of an account, the data storage of a smart contract, and transactions at both the account and contract level as they are executed. All of these actions change the "state" of the network.
Smart contracts are mostly written in the Solidity language. The EVM cannot directly execute Solidity, so the code must first be compiled into lower-level machine instructions called operation codes.
Operation codes - EVM language
EVM is widely known for its Turing completeness. This means that EVM can theoretically solve any computational problem. This is done by executing machine-level instructions called EVM operation codes (opcodes). EVM opcodes help the EVM execute specific tasks of a smart contract or transaction. Currently, there are about 150 opcodes that EVM can execute. They cover a range of operations, including arithmetic, halt, logging, duplication, sending, memory, comparison, and swapping. They also include fetching information about blocks and the environment. You can find a list of opcodes here.
For efficiency, the EVM converts its bytecode into opcodes, where each opcode is assigned one byte in the bytecode. Each opcode operation requires a certain amount of gas to execute in the EVM. You may have heard of gas, but what is it exactly?
Gas - fuel EVM
Gas is probably the most discussed and least understood topic related to EVM. At the time of writing, gas prices can be extremely high, but efforts are being made to improve this situation. High gas prices can be a significant barrier to mass adoption of Ethereum.
But why do we have to pay for gas, and why is the price so high? The purpose of gas is to act as a fee for the computational operations of smart contracts performed by each Ethereum node. There must be a fee for these computations to prevent a malicious actor from stopping the network by deploying a large number of complex contracts that require lengthy computations. This type of DDoS attack is not recommended because its execution will be very expensive.
Each operation code is assigned a gas cost, with more complex operation codes having a higher cost. For example, a simple addition costs 3 gas, and each transaction starts with a cost of 21,000 gas. Most complaints are not about gas itself, but rather the gas limit for a successful transaction.
Gas limit is the maximum amount of gas that the sender is willing to pay for the execution and verification of a transaction. To get paid for gas, you can multiply the total gas cost (the base values of the operations) by the gas price (the cost of executing those operations). Just like when filling up a car with actual gas, there is a cost for the gas itself and the amount of gas needed to reach the destination.
Gas fee = total gas cost x gas price.
The gas fee is intended to compensate the validator who is responsible for ensuring the accuracy of the information in the transaction, absence of errors/exceptions from EVM, and that the sender provides the necessary funds to pay for the computations. When the sender sets a high gas limit, it indicates that the operation is complex, which motivates validators to accept transactions for a high reward.
When network activity is high, validators can simply choose from the pool of pending transactions with higher gas limits. Thus, the gas fee depends on supply and demand. It's good that all unused gas is returned to the sender. If the pre-paid gas limit is depleted, the validator still receives compensation for their work, but the transaction does not complete. Thus, the EVM is quasi-Turing complete, as the computations it can perform are limited by the amount the sender is willing to pay for completion.
Use cases of EVM
Now that we have looked at each of the components of the EVM, let's see how these parts come together to help implement projects on Ethereum:
ERC-20 tokens
ERC-20 tokens are tokens that can be transferred between addresses, have a fixed supply, and their value is the same across the network. Smart contracts that follow a certain data structure in the EVM are used to create ERC-20 tokens.
This data structure manages the name, distribution, supply amount, and monitoring of the token. Several applications and projects use ERC-20 tokens to incentivize users. Livepeer, a decentralized video streaming network, uses the Livepeer token (LPT) to incentivize those who contribute resources to the network. Nexus Mutual, a decentralized smart contract insurance, uses the NXM token to allow users to purchase coverage and make claims.
Decentralized Exchanges
A decentralized exchange deploys smart contracts that allow users to exchange ERC-20 tokens. These smart contracts are called Automated Market Makers (AMMs) because they allow users to contribute to liquidity pools of certain tokens without the control of any third party. Some popular exchanges, such as Uniswap and SushiSwap, are applications of this AMM model.
ERC-721 tokens
Another widely popular token standard is the non-fungible cousin of ERC-20 - ERC-721. These smart contracts are used to mint NFTs (non-fungible tokens), which represent tokens with unique value on the blockchain. Creating unique works of art is the biggest use case for these types of tokens. Other gaming projects, such as Axie Infinity and Gods Unchained, use similar tokens for in-game operations and economy.
Popular blockchains compatible with EVM
Existing smart contracts can be easily deployed on other blockchains besides Ethereum, as the code has already been tested, verified, and often matches the product market fit.
It's important to note that EVM doesn't necessarily have to operate on the Ethereum blockchain. Essentially, these blockchains take the same code that was written for Ethereum and deploy it on their own blockchain. Chains compatible with EVM include:
- Avalanche (AVAX)
- Cardano (ADA)
- Ethereum (ETH)
- Ethereum Classic (ETC)
- Fantom (FTM)
- Harmony (ONE)
- Hedera Hashgraph (HBAR)
- Near (NEAR)
- Polygon (MATIC)
- TomoChain (TOMO)
Is EVM mandatory?
However, EVM-compatibility will create a strong network effect in blockchains, but the choice to be compatible or not depends on the blockchain's strategy. With non-EVM blockchains, developers must create their own developer community, while EVM blockchains can leverage the benefits of the available shared Solidity developer community.
Blockchains without EVM
Blockchains without EVM are blockchains with smart contracts written in languages other than Solidity. However, they can actually be compatible with EVM if they are built with some level 2 EVM compatibility.
Level 2 (L2) is a separate protocol designed to expand the functional capabilities of the blockchain. In cryptographic terms, the goal of level 2 is to scale the blockchain.
Below are the programming languages and a list of known blockchains without EVMs:
- Solana: Rust and C/C++.
- Cardano: Haskell and Plutus.
- Terra: Rust.
- Algorand: TEAL (Transaction Execution Approval Language).
- Near Protocol: Rust.
- …
Developers of dApps that are not related to EVM have to create their code from scratch in order to deploy their products on EVM-based blockchains. That's why they build EVM-compatible layer 2 solutions on top of base blockchains. For example, Aurora and Milkomeda are EVM-compatible layer 2 solutions on Near Protocol and Cardano, respectively. EVM and non-EVM blockchains are still competing in the crypto market. There is no clear winner yet. In our opinion, both types of blockchains will coexist and thrive in the crypto space.
What is the difference between EVM and non-EVM blockchains?
EVM-based blockchains can initially launch smart contracts written in Solidity code, while non-EVM blockchains cannot. Project developers take this into account when creating a new product to choose which blockchain platforms to deploy. This is undoubtedly a factor that affects the speed of a project's future success.
EVM and more
EVM makes Ethereum a platform, not just a blockchain. However, EVM is not a perfect system. There are many issues related to transaction speed and network throughput. This is an area of focus for the developer community and the roadmap for Ethereum. If Ethereum delivers on its promise to fundamentally change how we interact with each other, it will be thanks to improvements in EVM and, as developers claim, the long-awaited Ethereum 2.0 update and transition from Proof-of-work to Proof-of-stake protocol.