What is an Ethereum Virtual Machine (EVM) and how does it work?

Published at: Nov. 27, 2022

Ether (ETH), which is the second largest cryptocurrency in terms of market capitalization, is popular among cryptocurrency investors because of its native ETH token. However, its native Solidity programming language and Ethereum Virtual Machine (EVM) are instrumental in the adulation it receives from the developer community. In fact, the Ethereum blockchain continues to attract decentralized application (DApp) developers due to its flexibility, the vast range of developer tools available and the platform’s large user base.

Forming the core of the blockchain’s architecture, the EVM is the program that executes its application code or smart contracts, as they are called, providing a run-time environment for them that runs on top of the Ethereum network. What’s more, the EVM is Turing-complete and can thus run any program coded in any programming language, thereby allowing developers to easily create custom smart contracts and DApps for the burgeoning Web3 space. 

In addition to these important functionalities, EVM has access to all nodes in the network, handles smart contracts execution and effectively handles all transactions on the Ethereum blockchain, making it one of the most powerful virtual machines in existence today.

What is Ethereum Virtual Machine (EVM) and how does it work?

Conceptualized in 2013 by programmer Vitalik Buterin, the Ethereum network owes its phenomenal success as the preferred blockchain for DApp developers to the Ethereum Virtual Machine (EVM) that was designed by Gavin Wood during his tenure at Ethereum. Written in C++ and using the LLVM Project compiler, EVM is a special state machine that operates continuously and whose immutable operations determine the state of each block in the Ethereum blockchain. 

The EVM not only governs what nodes can or cannot do to the distributed ledger maintained by the Ethereum blockchain but also defines the specific rules of changing state from block to block. The latter functionality is what enables the smart contract functionality that Ethereum has come to be known for.

To understand what an Ethereum Virtual Machine does, one needs to look at each of the different functions it serves in ensuring the smooth operation of the Ethereum network. For every input that it receives, the EVM produces an output that is deterministic in nature and follows a mathematical function in the simplest sense. 

Operating like a stack machine that pushes transient values to and from a pushdown stack, the EVM has a depth of 1024 items, with each of them being a 256-bit word. It also maintains a temporary memory in the form of a byte array, which changes between two transactions on the Ethereum blockchain. Smart contract codes that have been compiled are executed by the EVM in the form of a collection of 140 standard opcodes, while other blockchain-specific stack operations are also implemented by it.

Thus, the EVM has a machine state that is volatile by nature during the processing of any transaction and a global or world state that contains information regarding the different accounts maintained on the Ethereum blockchain. All actions are governed by the EVM code, which in itself has gone through several iterations since the launch of the Ethereum network in 2015, leading to the existence of different implementations of the EVM currently in use.

In fact, the EVM is responsible for maintaining a level of abstraction between thousands of Ethereum nodes and the executing code, acting as a function that delivers consistent results without divulging many details to clients or nodes.

What is the purpose of the Ethereum Virtual Machine (EVM)?

The EVM has been reliably powering all applications running on the Ethereum network without any major downtime reported. For developers, the EVM acts as the overarching program that runs smaller executable programs which are known as smart contracts in Ethereum, while providing them the freedom to write these smart contracts in a variety of programming languages including Solidity, Vyper, Python and Yul, among others.

Due to this flexibility offered by the EVM, the Ethereum blockchain has spawned thousands of DApps in the decentralized finance (DeFi) and nonfungible token (NFT) space. Each of these DApps and the smart contracts that they are made of are converted into bytecode that is fed into the EVM and distributed among all nodes in the Ethereum network. When a smart contract is deployed, the EVM is responsible for communicating with all nodes and effecting state changes when a consensus has been arrived at.

It can be said that the EVM is inserted inside every Ethereum node to execute smart contracts using bytecode instead of the base programming language, thus isolating the physical host computer from the machine code on which Ethereum runs.

Benefits of Ethereum Virtual Machine (EVM)

On account of the way in which the EVM operates, developers can execute code without worrying about its impact on the rest of the network or the possibility of it playing truant with data or personal files hosted on any of the node computers. 

Additionally, they can run complex smart contracts on different computing environments with distributed consensus. This ensures that the failure of a single node does not have any negative impact on the running of the DApp or smart contract, since the EVM code remains the same across all nodes. Moreover, since account data is maintained at a global level in the EVM, developers find it perfect for writing custom smart contract code and creating distinct DApps that can access this global data set and produce reliable outputs. 

The sanctity of the outcome is what makes the EVM, in particular, and the Ethereum blockchain in general well-suited to the sustainable expansion of the DApps and smart contract Ethereum ecosystem. Add to this the library of standard codes available for developers to choose from, an increasing number of EVM-compatible layer-2 blockchains and a large number of potential EVM use cases possible, and it is easy to see why the EVM is the preferred platform for Web3 development.

Drawbacks of Ethereum Virtual Machine (EVM)

Despite the many advantages offered by the EVM, there are certain downsides that need to be considered by developers and entrepreneurs building on Ethereum. The most important of these is the high transaction fees or gas costs associated with running a smart contract on the Ethereum network. 

Paid in ETH, these fees vary depending on the complexity of the contract and the network congestion at the time of execution, making it imperative for developers and entrepreneurs to price their services accordingly. Additionally, since Solidity is the most preferred language for coding on the EVM, it does imply that developers need to have adequate experience with it and possess a modicum of technical expertise to create efficient smart contracts by using it. 

The latter is important since any additional computation requirement will lead to higher gas costs and ultimately prove detrimental to the project’s success. If developers choose to code using other languages, they need to be careful in resolving any inherent repetitions in the code since the EVM will proceed to compile them anyway. While upgrading smart contracts is possible at a later stage, it comes with security risks associated with creating an intermediary smart contract that references the address of the original smart contract.

The future of EVMs

Notwithstanding the revolutionary changes brought about by the EVM to the blockchain ecosystem, this technology for reading and executing code is being improved upon by a number of blockchain projects. 

With cross-chain interoperability being the most important aspect for developers, many EVM-compatible blockchains have propped up, with most offering lower gas and faster transaction speeds than the Ethereum protocol. As a result, these blockchains are now able to interact with Ethereum users seamlessly and are facilitating fund transfers to their own networks using blockchain bridges.

However, with the Ethereum protocol successfully completing the Merge in September 2022, the next target is to shift from EVM to Ethereum WebAssembly (eWASM). Designed to be highly modular and platform-independent, eWASM is being touted as the next game-changer for the Ethereum protocol and could motivate other blockchains to employ this run-time environment for smart contracts as well. However, whether eWASMs will replace the EVM as the most trusted mechanism for smart contracts is a question that only time will answer.

 

Tags
Related Posts
Blockchain is hard for developers and everyday users. Is it getting any easier?
For several years, one of the biggest hurdles to blockchain adoption has concerned the fact that it’s a rather technical space. Experienced developers find it daunting to build decentralized apps using this technology. Meanwhile, consumers unaccustomed to tokens and crypto wallets often struggle with user interfaces that are far clunkier than what mainstream platforms provide. With cryptocurrencies punching into the mainstream consciousness like never before, it has never been more important for blockchain platforms to seize the moment and offer the streamlined, easy-to-understand products and services that the masses can embrace with minimal hassle. As the old saying goes: “If …
Blockchain / April 16, 2021
Smart Contract Testing for Dummies
Smart contracts are immutable programs: Once a contract is deployed, it cannot be altered. This allows users to be sure that the rules by which their funds are operated will not be changed. However, the same feature makes creating secure smart contracts extremely complicated. If you create a contract with a bug or vulnerability, it is there forever. That’s why testing is even more crucial for smart contracts than for traditional applications. Related: What Are Smart Contracts? Guide for Beginners Why testing is necessary First, let’s clarify what problems tests can and cannot solve. For this purpose, let’s point out …
Blockchain / April 10, 2020
What is wrapped Ethereum (wETH) and how does it work?
Traders who use the Ethereum network are familiar with the ERC-20 technical standard and have most likely traded and invested in tokens that utilize it. After all, its practicality, transparency and flexibility have made it the industry norm for Ethereum-based projects. As such, many decentralized applications (DApps), crypto wallets and exchanges natively support ERC-20 tokens. However, there’s one problem: Ether (ETH) and ERC-20 do not exactly follow the same rules, as Ether was created way before ERC-20 was implemented as a technical standard. So, why does wrapped ETH matter? Briefly put, ERC-20 tokens can only be traded with other ERC-20 …
Blockchain / Oct. 1, 2022
How to learn Web3 development for beginners
The idea of Web3 has begun to take hold among business web developers in recent years. Modern business models emphasize the significance of moving beyond Web2 and discovering new ways to manage, organize and create meaning from the enormous volume of user-generated data, even though ideas about the current developments of the Web are still hazy and unclear. The Semantic Web is frequently linked to the concept of Web3 as business strategies and web developers envisioned it. Tim Berners-Lee, the inventor of the World Wide Web, initially proposed the idea in 1999. He saw the potential for enabling robots to …
Blockchain / Oct. 10, 2022
What are governance tokens, and how do they work?
Governance tokens are a type of cryptocurrency that allow tokenholders to vote on the direction of a blockchain project. The primary purpose of governance tokens is to decentralize decision-making and to give holders a say in how the project is run. Governance tokenholders are usually more invested in the project’s success as they stand to gain or lose more, depending on the outcome. Community members can use tokens to influence the direction and features of a blockchain protocol directly. As such, it is possible to implement changes related to the user interface, vote on fees and reward distribution, or even …
Blockchain / Oct. 24, 2022