Ethereum Virtual Machine Tutorial | Ethereum Blockchain

Tarulika  |  Jul 3, 2020

If you are into crypto space for a period of time, you might be aware of Ethereum Blockchain. Ethereum was created with an aim to provide a decentralized ecosystem for coders to design amazing applications using solidity coding language and EVM. Ethereum Blockchain is a dedicated network for developing smart contracts (digital agreements for automated execution of transactions). These smart contracts (one of the Ethereum applications) are successfully executed with the help of ETH Virtual Machines (EVM). These machines create a level of abstraction between the execution code and the execution machine. The layer of EVM is required to enhance the portability of software along with separating the applications from each other and also from their host. This article is primarily an “Ethereum Virtual Machine Tutorial” which will brief you about the EVM and related concepts.

What Is an Ethereum Virtual Machine?

Ethereum Virtual Machine or EVM is a sandboxed virtual implicit encompassed within each complete Ethereum node that has the potential to perform contract bytecode. Each and every node in the network of Ethereum works on EVM which permits them to agree on implementing the same executions. Smart contracts or simply contracts are generally imbibed in a higher-level coding language like Solidity and then congregated to EVM bytecode or programming language of EVM. This process ensures that the machine code is completely enclosed from the network, filesystem or any other process of the host computer.

What is Ethereum Virtual Machine

EVM is needed for the Ethereum Protocol and is mandatory for the consensus generator of the Ethereum system. It allows everyone to acquire code in a trustless ecosystem confirming the result of the execution, thereby being completely deterministic in administering smart contracts. Thus, EVM is one of the significant components of the Ethereum construction as it manages the internal state and computation on the network. Also, it handles the account information consisting of addresses, balances, current gas price and information of Block.

EVM Bytecode | EVM Programming Language

What powers Ethereum Virtual Machine in cryptocurrency? EVM Bytecode is the programming language of ETH Virtual Machine. The code for the contracts is written in high-level programming languages like Solidity (ETH Contract oriented language) which are compiled into EVM bytecode so that EVM can understand the written language. EVM can be executed with a number of programming languages like Java, JavaScript, Python, Ruby, etc. As the language got converted as per the convenience of EVM, it has the potential to perform any logical step of the computational function. Thus, the EVM achieves Turing Completeness after the transaction is sent to the network and gets validated along with the execution of associated code. Being Turing complete signifies that Ethereum which is technically a peer-to-peer for general purpose for the computer across the globe and could even predict the functions of the internet. The EVM executes the operation by charging per software instruction execution rather than the execution of the financial transaction. Let us understand more about transaction fees in the next section.

GAS | Transaction Fees | Ethereum Virtual Machine Tutorial

The Ethereum network is completely decentralised so there is no central authority for the execution of smart contracts, thereby the contract is executed on all the Ethereum nodes. So, to maintain the security and network free of congestion, every operational code has transaction fees or base GAS cost. For the implementation of every instruction on the EVM, a user has to reserve some quantity of Ether in exchange for GAS for the execution of code. Thus, GAS is a token which is used for executing the transaction on EVM. The main purpose of issuing the GAS token is to guarantee the validator of the initial pre-paid amount (if the execution fails!) and limiting the work required for operation.

GAS and ETH Virtual Machine

GAS actually serves as the tool to measure the fees for the execution code consisting of GAS limit which is the maximum amount a person can spend to buy GAS and GAS price that is the amount of Ether which an individual has to pay for each unit of GAS. So, both the GAS limit and price must be set beforehand of the execution. The price paid in terms of ETH coins is utilised to reward the miners for securing the Ethereum Blockchain rather than storing in any ethereum wallet or assistance provider.

Components Track By Ethereum Virtual Machine

Ethereum Virtual Machine or EVM is meant to handle the internal state of the Ethereum Blockchain network by tracking the status of numerous components to support the successful completion of the transaction. Ethereum is described as the transaction-based state machine as the state of components drives the level of change in the Blockchain network. The components which have been tracked by Ethereum Virtual Machine architecture are Account State, World State, Storage Sate, Block Information and Runtime Environment Information.

Components track by EVM

Account State

Ethereum consists of a number of small accounts that can capably interact with each other. There are two types of accounts, externally owned which have no code related to them and controlled by private keys and contract accounts which are based on codes and controlled by that code only. An externally owned account can send messages to both types of accounts with the help of digitally signing transactions using a private key. While the contract accounts can only interact with transactions serving as a response to other transactions which have been received either from externally controlled or contract accounts.

World State

The World State of Ethereum consists of a mapping of 160-bit address identifiers and account state. The information related to mapping is maintained in a data structure called the Merkle Patrica Tree consisting of leaf nodes (housing underlying data), intermediate nodes and a single root hash.

Storage State

Storage State is the information of a specific account which is maintained at runtime on the Ethereum Virtual Machine.

Block Information State

To support any transaction on Ethereum network, there are the state values or Block information tracked by Ethereum Virtual Machine. Block information consists of:

  • Block hash: Hash of recently completed Block
  • Coinbase: Address of recipient
  • Timestamp: Timestamp of the current Block
  • Number: Associated “number” of the current Block
  • Difficulty: Level of difficulty of current Block
  • Gas limit: Limit of GAS amount attached to the transaction
  • Runtime Environment State

    The information of execution of the transaction is tracked using runtime environment state which includes GAS price, codesize, caller or the address of account initiating execution and origin of the sender.

    While wrapping up this Ethereum Virtual Machine Tutorial, it can be advocated that the EVM plays an important role in the execution of transactions associated with smart contracts on Ethereum Blockchain. You can have the related coding information form EVM Github.

    Articles You May Read

      Related News