EVM Explained – What is Ethereum Virtual Machine?

Blockchain has gone from a seeming niche technology to truly breaking into the mainstream. You hear about it in the news, read about it in blog posts, and see that it can be applied to many sectors, not just finance or tech. Blockchains have global significance and have the potential to transform many different industries. If you’re just getting acquainted with blockchains, learning about Ethereum and the Ethereum Virtual Machine is a good place to start.

If you’re a beginner or programmer who is new to blockchains, you might encounter the term Ethereum Virtual Machine (EVM). So, what is this, and how did this idea come about? Ethereum’s creators were clear about their vision from day one. They wanted it to be a “world computer” or an “internet computer”. How does it accomplish this ambition? Part of the answer lies in the Ethereum Virtual Machine (EVM). What’s more, Moralis – the premier blockchain middleware – has extensive EVM support. We’ll dive into what EVMs are and why this support can be so valuable when you build dApps with Moralis!

Before you embark on a study of “what is Ethereum Virtual Machine” or EVM, you will need some background on concepts like Turing-complete machines and virtual machines. You also need to understand how decentralized ecosystems work. Bitcoin was the first to introduce a decentralized ecosystem. A few years after Bitcoin was launched, developers began to warm up to the idea of “internet machines” or virtual machines running the world. The idea of more powerful and complex blockchains captured their imagination. This directly relates to the notion of Web3 and a decentralized web. So, let’s dive into the specifics of EVMs!

What is Ethereum Virtual Machine?

When reading the Ethereum yellow paper, or coming across various descriptions of Ethereum on the web, you might find yourself asking, “What is Ethereum Virtual Machine?”

Understanding the EVM is essential to grasping the ecosystem as a whole. But before you answer this question, you need to break down your learning sequence into several parts. Ethereum has many components, and you need to understand how they all work together.

Virtual Machines

First, you need to understand what a virtual machine is. Virtual machines are machines that attempt a higher level of abstraction than your usual operating system or OS. Unlike Windows or iOS, virtual machines or VMs are created on top of the usual operating systems so they can function similarly to a physical computing machine.

In other words, virtual machines approximate the computing power of physical machines using virtual architecture. They can run on many different types of OS’s and hardware, making them the perfect engine for a decentralized ecosystem.

Through a VM, one can use the resources of network participants regardless of location or geography to build, process, and execute what they want. In this sense, the EVM acts like a global processor or computer that lends its accumulated computing power to developers. The developers, in turn, use this resource to create smart contracts and decentralized apps or dApps. 

A virtual machine can be accessed from anywhere in the world through participating Ethereum nodes. Lending computing power to the network is voluntary and is governed by several incentives. Given all the properties of virtual machines, and the need to process all of the data through a voluntary network, it makes sense for Ethereum to choose the VM type of architecture.

What is Turing-completeness?

When answering “What is Ethereum Virtual Machine?”, you will come across terms such as Turing-completeness. The EVM is Turing-complete. What exactly does that mean? The concept came from renowned computer scientist Alan Turing. He developed ideas around what a hypothetical computer or thinking machine can do. He argued that computers do not think or process thoughts like human beings, but go by a set of data processing rules to solve problems. 

How Turing Machines Think

A Turing machine, once referred to by Turing as an a-machine (for “automatic machine”) is a hypothetical machine that embodies his concept of non-human or machine thinking. The thinking process runs by way of algorithms. In Turing’s paper, he mentioned that such a machine would have to process a reel of tape with a line of symbols or functions that can be moved backward and forward. One could also picture a read/write head that would move between these functions. Ergo, the machine would be capable of processing a symbol or altering it. Such a machine could only direct its attention to one “state” at a time. (The concept of “statefulness” is useful in understanding EVMs).

There is no proposed limit for such a tape. It is hypothetically infinite and only constrained by physical limitations. The tape corresponds to a computer’s memory. Hence, the memory can be infinitely added to by adding to the length of the reel of tape. Thus, when a computer has to follow a set of instructions, the data applied to such instructions is only limited by physical constraints. 

These ideas are fundamental to understanding “What is Ethereum Virtual Machine?”, as they comprise the basic principles of its concept and architecture. From Turing’s largely “physical” idea of machine processing, others derived a virtual counterpart, with essentially the same operating principles. 

JavaScript in ETH

In summary, a Turing-complete system can perform any logical step of a computational function. Programming languages, not just machines, use Turing-completeness. One of these is JavaScript. JavaScript is an important programming language needed to work with Ethereum and the EVM, as well as understand the syntax behind the programming language of Ethereum smart contracts, Solidity. 

To learn more about JavaScript and how it ties into Ethereum, you can read our introduction to JavaScript and Web3.js. If you are interested in a primer on Solidity, you can read our Solidity post for a more holistic understanding of smart contracts. Ivan on Tech Academy has an excellent course on JavaScript and its relevance to blockchain, so be sure to check it out. 

What is Ethereum Virtual Machine or EVM

Now that you have a basic idea of what a Turing-complete machine is and an overview of how virtual machines work, we are closer to understanding “what is Ethereum Virtual Machine” or EVM in particular. 

Interest has gathered around Ethereum in recent years, as it has proven to be a breakthrough concept in blockchain and in the creation of decentralized networks that do more than process basic cash transactions. 

If you are a more advanced developer and understand how Ethereum works already, you will find this review important as the network transitions into Ethereum 2.0, which means that it will move from the Ethereum Virtual Machine (EVM) to eWASM on Ethereum 2.0.

Developers who are interested in more advanced tutorials on Ethereum smart contracts and EVM can sign up for Ivan on Tech Academy’s Ethereum Smart Contract Programming 201 classes. These courses provide you with in-depth knowledge on how to succeed in this space. They also help you get certified so you access more employment or advancement opportunities as you apply your skills to numerous projects. 

Ethereum Virtual Machine Features

If you are familiar with Bitcoin and already use it, you will sense how straightforward it is. While decentralized, bitcoin deals mainly with transactions on its virtual machine. It is also limited to being a decentralized distributed ledger. 

A Distributed State Machine

Ethereum attempts something larger in scope. It is not just a distributed ledger, but something much more sophisticated. The main Ethereum website describes it as a “distributed state machine”. Ethereum does not only hold data on accounts or balances, but holds an entire machine state. 

Its machine state varies with every block, as the machine transitions with every set of programs it runs according to certain fixed rules. What determines these specific rule-based state changes? It’s the Ethereum Virtual Machine.

The Ethereum protocol also utilizes smart contracts, which are coded instructions that interact with the Ethereum Virtual Machine or EVM. These smart contracts are programs that cover many different aspects of human agreement or at least simulate them. Through this you can see why the underlying design of Ethereum needs to be far more complex than Bitcoin. 

While Ethereum adapts a complex structure, its developer-facing programming language does not. To bring in more contributors to the ecosystem, the founding team decided on a more user-friendly programming language that was relatively easy to learn. Solidity, the language in which Ethereum smart contracts and dApps are written, was designed to be relatively simple. It mimics human communication patterns. It attempts to be more expressive and more user-friendly in its syntax. Thus you have this high-level user-friendly language that tells the machine what to do. 

Smart Contracts

When trying to understand “what is Ethereum Virtual Machine”, you need a good grasp of smart contracts. In their simplest definition, smart contracts are agreements between parties that are written in lines of code. They are self-executing; meaning, they do not need trusted party supervision to get done. They allow parties to transact with each other in a trusted manner anonymously, from all over the world, without any authority to validate their shared transactions. The execution of such transactions does not depend on any legal system or enforcement mechanism either. Smart contracts are made possible because of the way the Ethereum network is designed. They also access the Ethereum Virtual Machine or EVM.

Smart contracts, as reflected on the blockchain, are immutable and transparent. Because smart contracts are immutable and still need to be able to run through multiple nodes without being compromised, the EVM or Ethereum Virtual Machine has the following features:

Ethereum Virtual Machine is Deterministic

A program is deterministic when it provides the same output to the same set of inputs. It doesn’t matter how many times the code is executed. This is important because decentralized apps or dApps on Ethereum may handle financial transactions involving large amounts of money at any given time. Therefore, it is crucial to know how the code will react in every stage of execution. Determinism is essential to the foundations of the Ethereum Virtual Machine. 

Ethereum Virtual Machine is Isolated

Another important characteristic of smart contracts is that they run in isolated environments. Isolation is facilitated by two systems: Virtual machines and docker containers. Since the contract designs in Docker are not deterministic, Ethereum selected virtual machines to enable this feature. 

Isolation is important so that the system can contain hacks or bugs within a smart contract. The feature is in place so that such issues or incidents do not affect the underlying protocol. 

Ethereum Virtual Machine is Terminable

As mentioned in the above sections on Turing-completeness, the EVM is Turing-complete, which means its smart contracts can solve any type of problem, at least hypothetically. But there is no way to tell whether such smart contracts can finish all the given operations within a specific time frame. Therefore, it is essential to put in a terminating mechanism to create exact limits. In Ethereum, the concept of “gas” is used to facilitate traffic. Gas is also part of the incentive mechanism of the network, whereby gas fees are used to selectively determine which functions should be run or prioritized. Gas limits are set at the beginning. When these limits are used up, the machine simply stops operations or halts its processing.

The EVM Economy

The EVM creates an economy. Through gas incentives, it fosters a peer-to-peer Turing-completeness, making use of the resources of the world to run programs. Through this, it lives up to its vision of a “world computer”. How is the EVM essential to the protocol? It allows anyone who joins the network to execute their code in a trustless manner where the outcome of any execution is guaranteed via fully deterministic (see above, under EVM features) smart contracts.

With a way to measure gas costs to execute a smart contract, the protocol guarantees that fees are received before running the program, thus protecting the incentives and priority system. Ethereum has validators that ensure that all the information on each network transaction is valid; that the funds held by the sender are sufficient to pay for the execution of the smart contract, and that the EVM, in the process of executing the function, did not run into exceptions.

Getting Started

Each participant in the system can download an implementation of Ethereum. After installation, you are ready to run a full node and initialize a blank-state copy of the EVM. You then begin downloading the Ethereum history, which means you download all the blocks, starting from block zero. This process can take time. You will need to replay the transactions of all the blocks in order until it reaches its present state.

Save Time on EVMs with Moralis

Running a full Ethereum node on your own can be taxing and time-consuming. If you are a developer who already understands how everything works and just wants to get started on creating and shipping dApps right away, Moralis provides a solution. 

To shorten your development and completion time, you can check out Moralis’ products to connect to the blockchain right away and to do it reliably via Moralis Speedy Nodes. You can ship dApps in record time over Ethereum, Polygon, or BSC. 

EVM and dApps

By understanding “What is Ethereum Virtual Machine” you are on your way to being part of this remarkable economy where you don’t just get to be a passive actor, but also a creator. Developers can use their creativity by building dApps that create value and solve problems in many different ways. By tapping into the power of this world computer, you can create so many things such as markets, events, file-sharing economies, new infrastructures for finance, and new ways of trustless interaction. You can also create decentralized versions of different business models. The opportunities are endless. 

With tools like Moralis that help you build serverless dApps without having to set up your own Ethereum node and back-end infrastructure from scratch, you can take advantage of the exponential growth in blockchains and be on your way to increased productivity.

 

Share on facebook
Share on twitter
Share on linkedin
Moralis Blog
Moralis Blog

Related Articles

Become a Web3 Expert
Subscribe to our newsletter and get our E-book Web3 Speed run for FREE