What is EVM?

When a smart contract runs on Ethereum it’s executed by the Ethereum virtual machine. In this short article, I will give you a quick intro to the Ethereum Virtual Machine (EVM), the most interesting part of Ethereum. If you are new here, I’m Ayush, a …


This content originally appeared on DEV Community and was authored by Ayush Gupta

Image description
When a smart contract runs on Ethereum it's executed by the Ethereum virtual machine. In this short article, I will give you a quick intro to the Ethereum Virtual Machine (EVM), the most interesting part of Ethereum. If you are new here, I'm Ayush, a member of the Get Into Web3 community, where we make it easy for people to get started in Web3.

The Ethereum network is composed of computers called nodes. The EVM runs inside each of these Ethereum instances and the role of the EVM is to run smart contracts. The EVM is a state machine. In input, there is the state of the existing blockchain, and in output, the state is updated after a transaction has been applied.

Image description

The state of the blockchain is a mapping of accounts identified by the address to four fields-

  1. the nonce that is incremented for each transaction,
  2. the balance of ether owned by this address,
  3. the hash of the smart contract code, and
  4. the hash of the smart contract storage

Image description

The last two fields are populated only for smart contracts. For regular addresses called EOA, they are empty. The EVM can be executed in read mode and write mode.
In read mode, a user sends a request to any node of the network and the EVM of this node will process the request. In write mode, users send transactions that are mined by miners in the Ethereum network.

In each mining node, the EVM is going to process all the transactions of the new block. Each transaction is processed sequentially by the EVM in an order decided arbitrarily by each miner. For each transaction, the EVM is going to check if the transaction is valid, compute the new state of the blockchain and persist the state. For example, an address can increase its ether balance or its storage is modified. The process is repeated until all transactions are executed for this block. The miner that wins the block will propagate the new block to the network containing the hash of the new state. One important detail of the EVM is how it processes smart contracts?

Image description

Smart Contracts are basically a set of promises, specified in digital form, including protocols within which the party is performing on these promises. It's a reusable snippet of code that a developer publishes into the EVM memory. Smart contracts are often written in a programming language called Solidity. Smart contract languages like Solidity cannot be executed by the EVM directly, instead, they are compiled to a low-level machine language called opcodes. To execute specific tasks in order to efficiently store these occurrences, they are further encoded to bytecodes. Now, anyone can request the smart contract code to be executed by making a transaction request.

Image description

There comes the concept of Gas. In Ethereum, gas is essentially the fuel that allows the Ethereum network to operate. They have a market price determined by the demand for resources on the network. The amount of gas you need depends on how complex of a smart contract function you are trying to execute and how fast you want to execute it. The gas fee keeps the Ethereum network secure, preventing actors from scamming the network.

The potential use case of the EVM and decentralized apps are huge and developers are working every day to make the entire ecosystem better.

That's it for this quick intro to the Ethereum virtual machine (EVM). Going forward, if you want to know more about the technologies associated with Web3, don’t forget to follow and be a part of the Get Into Web3 (GIW3) community for the latest updates. Also, don't forget to follow us on Twitter and join the Discord community to learn more.

See you soon reading my next blog :)


This content originally appeared on DEV Community and was authored by Ayush Gupta


Print Share Comment Cite Upload Translate Updates
APA

Ayush Gupta | Sciencx (2022-02-01T15:22:03+00:00) What is EVM?. Retrieved from https://www.scien.cx/2022/02/01/what-is-evm/

MLA
" » What is EVM?." Ayush Gupta | Sciencx - Tuesday February 1, 2022, https://www.scien.cx/2022/02/01/what-is-evm/
HARVARD
Ayush Gupta | Sciencx Tuesday February 1, 2022 » What is EVM?., viewed ,<https://www.scien.cx/2022/02/01/what-is-evm/>
VANCOUVER
Ayush Gupta | Sciencx - » What is EVM?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/01/what-is-evm/
CHICAGO
" » What is EVM?." Ayush Gupta | Sciencx - Accessed . https://www.scien.cx/2022/02/01/what-is-evm/
IEEE
" » What is EVM?." Ayush Gupta | Sciencx [Online]. Available: https://www.scien.cx/2022/02/01/what-is-evm/. [Accessed: ]
rf:citation
» What is EVM? | Ayush Gupta | Sciencx | https://www.scien.cx/2022/02/01/what-is-evm/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.