ETHEREUM VIRTUAL MACHINE

The Ethereum Virtual Machine

The Ethereum Virtual Machine, or EVM, is a piece of software that executes smart contracts and computes the state of the Ethereum network after each new block is added to the chain.

The EVM sits on top of Ethereum's hardware and node network layer. Its main purpose is to compute the network's state and to run and compile various types of smart contract code into a readable format called 'Bytecode.'

This makes it possible for smart contracts deployed on EVM-compatible chains like Polygon or Avalanche to be recognized by Ethereum nodes and allows developers to port their dapps or tokens over from Ethereum to other EVM-compatible chains with relative ease. Purpose of EVM

Purpose of EVM

The Ethereum Virtual Machine (EVM) is a Turing complete programmable machine, which can execute scripts to produce arbitrary outcomes. It has been built with the purpose of being a “world computer” and has immense power.

  • It is the computer that stores data on blockchain, like bitcoin, but it also executes code in smart contracts on the Ethereum network.
  • The machine is made to be able to run any kind of Crypto-contract that can be built on Ethereum’s blockchain. It does this by using a programming language called Solidity, which is compiled into the EVM for execution.
  • The intention behind writing code on the Ethereum network is to create smart contracts and programs that automatically execute things when certain conditions are met. If a terms or condition is not met, the system can execute it in an “exit” function as well.
  • For example, if an account has been hacked, the hacker cannot steal money from the system, because they don’t have the budget or authority to do so.

How Does EVM Works?

Ethereum Virtual Machine (EVM) is a program which executes scripts used to implement certain operations usually in Ethereum blockchain.

The Ethereum Virtual Machine makes the process of creating new tokens on Ethereum Blockchain easy. Here, script means a set of instructions or an algorithm which tells the computer what it needs to do in order for something to work properly. The EVM requires that one has access over any network node so as to be able to execute the desired commands and create new tokens on the blockchain without any difficulties.

  • In Ethereum, there is something called a smart contract. These contracts have some computer code which facilitates the exchange of money and information.
  • These contracts are predefined by the creator of the smart contract, in order to ensure that a certain outcome will happen based on either what happens or doesn’t happen.
  • Ethereum Virtual Machine provides Turing complete environment for execution of scripts and smart contracts. This means that anything that can be implemented with a computer can be run on EVM.

In the Ethereum ecosystem, EVM plays a vital role by providing a platform for decentralized applications (DApps) to be built on top of it.

Ethereum Virtual Machine ensures that all transactions and smart contracts made on the Ethereum blockchain are executed in correct and expected manner as desired by the smart contract code. It serves as a platform for applications to be executed on.

In simple words, it can be said that Ethereum Virtual Machine facilitates DApp creation and execution on the blockchain.

Ethereum Virtual Machine (EVM) has two parts:

  • EVM (the part that runs solidity source code): The EVM is written in C++ and uses LLVM as its compiler. It is a full-featured virtual machine with all the features that you would want in a general purpose Smart Contract Virtual Machine, such as support for multiple programming languages, security features, runtime environments and more. It also allows you to write custom EVM bytecode .
  • Uncles: These are small pieces of smart contracts or data stored on the blockchain. This is a useful feature because it allows for you to store metadata about your program. EVM Assembly: This is the bytecode of EVM, which you can use as your programming language.

These are small pieces of smart contracts or data stored on the blockchain. This is a useful feature because it allows one to store metadata about the program.

  • Actions:Actions: These are basic operations that one can perform on assets stored in memory (and not on the blockchain), such as multiplication, addition, and so on.
  • Balance:This is the amount of Ether that one have at any time. So, if there is a balance of 100 Ether and spend 10 Ether, the balance would be 90 Ether. Note that this is not actually a variable, it’s just a part of memory where EVM stores the data. This means that whenone tries to modify or read from it, it will return execution with an error.
  • Block:This is an immutable storage for all actions and transactions related to Ethereum in its lifetime up until this block in particular. These blocks can be only 65,000 so this is not going to change.
  • Blockhash:This is a hash of the block in question. So, if you are looking at stored on the blockchain under another name, this would be a hash of the data stored there.
  • Block Number:This is a number indicating which block this particular blockhash belongs to. It always starts from zero and increases every time there’s a new block added to the chain. Note that blocks have timestamps associated with them so you can tell how much time passed between two blocks.
  • Code:This is code executed in EVM that determines what action is going to be taken when an input happens (such as transferring money).
  • CodeHash:This is a hash of the code itself. If one looks at a contract on Etherscan, the CodeHash is what one will see. When functions are executed on EVM, this number changes because the code itself changes based on the input.
  • CodeSize:This is the actual size of the code in bytes.
  • GasLimit:This is a part of EVM that allows for users to specify how much gas they are willing to spend in order to execute something. If this number is zero, then nothing will happen (this rarely happens).