fbpx

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

Ethereum, it’s a network blockchain who first introduced the concept of programmability smart contracts. How the network works and what it basically is all about Ethereum, you will find in our previous lesson.

The network ecosystem provides the basis for creating, compiling, and executing thousands of smart contracts. How? Thanks, Ethereum Virtual Machine (EVM). In today’s lesson, we will discuss this concept in more detail.

Ethereum Virtual Machine – definition

EVM is software whose task is to create and compile smart contracts into a readable format called Bytecode. Simultaneously, EVM calculates the state of the Ethereum network after adding each new one block to the chain.

Ethereum Virtual Machine, it sits on top of the hardware and network layers of Ethereum. What else is interested in EVM? Smart contracts deployed on other z-compatible chains EVM (e.g. Polygon or Avalanche) are recognizable by nodes in Ethereum. As a result, developers can move theirs relatively easily dApp’s the tokens from Ethereum to other chains, compatible with Ethereum Virtual Machine, programmed in the language Solidity.

In the crypto industry, EVM is often referred to as “the heart of Ethereum”that drives the entire network ecosystem.

How does the Ethereum Virtual Machine work?

The operation of EVM can be divided into two separate sections – creating tokens and smart contracts. Let’s take a closer look at this topic.

Ethereum Virtual Machine facilitates the process of creating new tokens on Blockchain Ethereum. As we mentioned earlier, EVM is a program that facilitates the creation of scripts used to implement operations on Blockchain Ethereum. A script is a set of instructions or an algorithm that tells the “computer” what to do to make something work properly. In its action, EVM requires developers to have access to any network chain to be able to execute the desired commands and create a new one token already blockchain without any difficulty.

Now that you know how new ones are made tokens using EVM Now let’s look at smart contracts. On the Web Ethereum there are plenty of them. They have a defined code that makes it easy to replace cryptocurrencies and information. Such agreements (codes) are defined by the creator smart contract and provide a certain result.

Ethereum Virtual Machine provides developers and creators with a smart contracts environment Turing Complete where they can create scripts and contracts. This means that anything we implement with a computer, we will run with EVM.

EVM plays an essential role in the ecosystem of Ethereum. Creates an environment for decentralized applications (dApps)which we build at the top of the chain. If you forgot what decentralized dApps are, take a look here.

The Ethereum Virtual Machine assures us that all transactions and intelligent contracts on the blockchain Ethereum are executed in the correct way, according to the predetermined code of the intelligent contract.

Simply put, EVM is a platform that makes it much easier for developers to create dApps and implementations on blockchain.

EVM – construction

Ethereum Virtual Machine is made of two parts. The first one runs the source code Solidity. EVM is written in C++ and uses LLVM as its compiler. EVM supports many programming languages, security, and runtime environment for codes. It also allows developers to write custom EVM bytecode.

The second part is called uncles. So, little pieces of smart contracts or data stored on blockchain. It allows you to store metadata. Which ones?

  1. Information about the basic operations that we can perform on assets stored in memory (not on the blockchain!).
  2. What is the balance of Ethereum that someone has at the moment.
  3. Storage of all activities and transactions related to Ethereum.
  4. Information about the hash of a given block.
  5. Information about the so-called block number, which is a number indicating which block a particular block hash belongs to
  6. Code executed using EVM. It determines what action will be taken when a given input occurs (e.g. transfer of money).
  7. Actual code size in bytes.
  8. Part information EVM, which allows users to determine how much gas they are willing to spend to get something done.

Someone said –gas? Now, we may ask – but what does it actually have to do with EVM performance? Oh well, gas is a measure of computing power. Simply put, it defines the time it takes to execute the transaction’s contract. Because there is so much code in the entire ecosystem, a certain amount of gas is used to run it “upfront”. The default limit is set to 250,000 units. Remember that the more complicated it is a transaction, the more gas is needed to make it.

Advantages of EVM

  • Reduces the risk of untrusted code execution, without compromising confidential data.EVM guarantees developers that their calculations won’t interfere with others (system or what’s going on in personal files).
  • Allows you to run complex smart contracts. Thanks to Ethereum Virtual Machine we can run complex smart contracts without worrying about how they will affect each other. You can write them once, but run them on many platforms. This allows you to create one smart contract that runs on multiple platforms.
  • Deterministic processing. Smart contracts written using EVM have access to all networks in Ethereum at the moment. As a result, it allows processing in a deterministic manner and gives a much greater guarantee for their correctness.
  • Dispersed consensus. Ecosystem Ethereum allows most users to run the same program on their computers.
  • Ease of writing stateful contracts. EVM is intended for writing smart contracts and creating dApps. To sum up – programs running in distributed networks, while ensuring that everyone sees the same version.EVM, it also makes typing easier stateful contracts that have access to non-volatile memory.

Disadvantages of EVM

  • Very high cost of data storage. In short – gas. That is, what we use when paying the launch fee smart contract.
  • High cost of data storage blockchain. It can take over 3TB.
  • High technical knowledge required. Writing smart contracts and simultaneous use of EVM requires quite a bit of technical knowledge. We’re talking about the environment Turing Complete which allows programmers to write in any programming language. For some it is wonderful, for others (with less knowledge and sophistication) it can be even

Blockchains compatible with EVM

Interoperability between Ethereum blockchains turned out to be a significant problem for developers. High gas charges and slow transactions forced Ethereum developers to create Dapps and smart contracts on the other blockchains. Thus, they could offer faster transactions and lower fees. Unfortunately, it could not be so easy and beautiful. Many of these blockchains have severe limitations and lack interoperability with other blockchains.

EVM compatible chains solve this problem perfectly. Developers don’t have to start from scratch and create an environment like Ethereum Virtual Machine. They copy certain elements of Ethereum network and create dApps’y, allowing users to quickly and easily transfer assets between any network’s EVM.

Thanks to such interoperability of the most used, network blockchains follow the most compatible EVM.

Examples of blockchains working with EVM:

  • Binance Smart Chain
  • Avalanche
  • Phantom
  • Cardano
  • Polygon
  • Tron

Sidechain of the above-mentioned ecosystems are compatible with EVM. They offer benefits and reach Ethereum Blockchain, with significantly higher speed, capacity and lower transaction fees.

EVM use cases

Now that you know what EVM is and how it works. Let’s take a look at how everything connects and supports the EVM ecosystem and other Ethereum-based projects.

ERC-20 tokens

ERC-20 tokens act as a motivator for users dApp and Ethereum projects. They are specifically designed to be easily moved between networks and retain their value. ERC-20 tokens are created by smart contracts, based on specific data structures.

AMM and DEX 

DEX, enable the exchange of ERC-20 tokens, thanks to smart contracts. In turn, just these smart contracts enable exchange users to use the liquidity pool, without the need for third-party integration. Thus, they are given the title AMM – automated market makers. This group includes, among others: SushiSwap, Uniswap, or several other popular exchanges.

ERC-271 tokens

Another type of token that is used in the EVM ecosystem, the token ERC-271. Very often, this type of token is used to mint non-fungible tokens (NFT).

Just a few years ago, when cryptocurrencies just saw the light of day, it would be unthinkable that a piece of code would have the ability to democratize virtual access to art markets. God Unchained, Axie Infinity, Decentraland are just a few examples of the games they use ERC-271 in the game as collectibles.

DeFi

Cardano and its decentralized exchange AMM AdaSwap. Thanks to cooperation with Milkomeda and Layer 2 sidechain solutions, Milkomeda gives blockchain such as EVM compatibility. Thanks to this solution, basically sidechain, users can transfer assets and run Cardano dApps already Ethereum and vice versa.

DAO

It’s worth knowing that EVM is managed by the DAO, which is a decentralized autonomous organization. DAOs are fully autonomous and transparent. In smart contracts, they set the rules by making decisions based on instructions written in code. However, this does not prevent system users from voting and submitting consensus proposals. Fun fact: even the code itself can be based on a public audit. Thanks to this, every member of the DAO community understands how the protocol works at each stage.

If you want to remind yourself what it was and what are the most important features of DAO, we refer you to our lesson.

How does EVM work?

And now something for fans of mathematics and computer science. Ethereum Virtual Machine works very much like most maths functions. Why? Because it can generate a deterministic output for any input.

EVM, it mainly refers to status and transactions. Where the state of the EVM is described as a data structure, and transactions are instructions for action from different accounts, cryptographically signed.

The state, or rather the data structure, is known as the modified Merkle Patricia Tree. It keeps a record of all accounts linked together by various kinds of hash. Interestingly, “state” in functions EVM may refer to a specific hash on Blockchain Ethereum.

Transactions. It’s worth knowing that Ethereum Virtual Machine supports up to two transaction variants. However, only one of them triggers the message and the other creates it contracts. Creating a contract leads to the creation of a new account containing smart contract bytecode.

Opcodes 

If you have studied our lessons carefully, this term has come up many times before. Especially when we discussed the network itself, Ethereum or related topics. Why are we mentioning them now? Opcodes are an integral part of each EVM implementation.

Opcodes supported by Ethereum Virtual Machine help him to carry out specific tasks related to smart contracts and the EVM cryptocurrency transactions, but not only! They also have other uses – they record data and arithmetic tasks, or retrieve information about a block.

Fun fact: opcodes don’t have a direct script in EVM. As a result, they can help developers create and interact with smart contracts effortlessly.

Summary

If you’ve ever interacted with an ecosystem of Ethereum, you must have heard about Ethereum Virtual Machine. A virtual machine without any physical limitations. It does not require any high-end equipment for its operation. EVM is also a great environment for easy development and deployment of smart contracts.

Sign up for the newsletter!

Receive the latest cryptocurrency news in your email every week.