Blog_eng

EVM (Ethereum Virtual Machine)

Crypto Fundamental

The Ethereum Virtual Machine (EVM) is a software platform that developers can use to create decentralized applications (DApps) on Ethereum.

Ethereum has created a virtual environment that allows smart contracts to interact with each other, which it calls the Ethereum Virtual Machine. This allows smart contracts to have more functionality without increasing complexity.

A bit of backstory


A while after Bitcoin came along and gave blockchain technology the attention it deserved, Ethereum came out and allowed people to create smart contracts and Dapps using blockchain technology.

Once Ethereum allowed the creation of smart contracts, the next step was to create an environment in which all these smart contracts live and interact with each other. This is where the Ethereum Virtual Machine (EVM) comes into play.

An EVM is best thought of as a virtual computer on a blockchain that turns your ideas into code and runs it on the global Ethereum network.

An example of how an Ethereum virtual machine works


Let's say you want to create a way for yourself and your friends who live in the same apartment to buy things for the house you live in. Essentially, you're creating your own smart contract.

There are a number of things you want your smart contract to cover.
  • You and your friends must create individual accounts.
  • You all agree to withdraw some of that money from your individual accounts and deposit it into your current account each month.
  • You all agree that no one can withdraw money from this account unless everyone agrees.
  • All that money can only be withdrawn from that account if all of you provide a digital signature.

Now everything works, but let's say that you want to allocate a certain amount of money each week to buy things for the house. You create a separate smart contract that says:
  • Spend only $10 a week on home goods.
  • Buy only home goods from this store.
  • Make sure the items from that store are delivered to that address.

Then, for example, you want to buy a TV, but some of your friends only want to deposit a certain amount of money for it. This is where another contract comes in. This contract reads:
  • Person A is only willing to spend $20.
  • Person B is willing to spend $40.
  • Person C can only spend $10.
  • User D can make up the difference and buy a TV if the above conditions are met.

Can you see how all of these contracts depend on those created before these contracts? This is the Ethereum virtual machine. The environment in which all these contracts live, interact, and influence each other.
It's like a messaging service for smart contracts.


How does the Ethereum virtual machine work?


An EVM works as a stack machine with a stack depth of 1024 elements. Each element is a 256-bit word, which has been chosen for ease of use with 256-bit cryptography (for example: Keccak-256 or secp256k1 signatures).

At runtime, EVM maintains temporary memory (in the form of an array of bytes with word addressing) that is not stored between transactions.

Contracts contain Merkle Patricia tree storage (in the form of a word-addressed word array) associated with the account in question and part of the global state.

The compiled smart contract byte code is executed as a series of EVM operation codes that perform standard stack operations such as XOR, AND, ADD, SUB, etc.
EVM also implements a number of blockchain-specific stack operations such as ADDRESS, BALANCE, BLOCKHASH, etc.

EVM Implementation


All EVM implementations must conform to the specification described in Ethereum Yellowpaper.

Ethereum EVM has undergone several changes throughout its history, and there are several EVM implementations in different programming languages.

All Ethereum clients include an EVM implementation. In addition, there are several standalone implementations, including:

The advantage of EVM?


In addition to avoiding pitfalls from your friends, EVM can do a lot more:
  1. You can create contracts that require several conditions to be met: insurance contracts, for example.
  2. You can allow different people to specify their own mini-contracts in larger contracts. Imagine a builder hiring contractors to build a house. He could have mini-contracts between his plumbers, plasterers, and electricians that pay each person only if certain conditions are met.
  3. You can create contracts that can automatically buy or sell things: let's say you work in air conditioning. You only want to buy air conditioners when the temperature rises above a certain point. You can create a smart contract that can take into account the weather and automatically buy the thing you want when you need it.

Virtual Machine Language


EVM has its own programming language called Solidity. It is a language that allows people to create smart contracts that can easily interact with other smart contracts.

Conclusion


We are only at the beginning of becoming, the development of the virtual machine. In the future, the complexity, speed, and capabilities of the virtual machine will only increase as technology and technical capabilities are constantly evolving and improving.

Thank you for your attention and hope this article was useful for you.

Good luck to you friends on your way and see you soon!

Always yours C.J.

Made on
Tilda