Understanding EVM for Ethereum

SP
Coinmonks
3 min readMay 3, 2023

--

Ethereum Virtual Machine(EVM)

What is EVM?

EVM stands for Ethereum Virtual Machine. It is a runtime environment for smart contracts in the Ethereum blockchain. Essentially, the EVM is a virtual machine that executes code written in Solidity, the programming language used for developing smart contracts on the Ethereum platform.

The EVM provides a sandboxed environment for executing code, which means that it prevents smart contracts from interfering with each other or with the Ethereum network. The EVM also ensures that smart contracts are executed in a deterministic way, so that the same code will always produce the same output.

In addition to executing code, the EVM also maintains the state of the Ethereum blockchain. This includes keeping track of account balances, contract storage, and other important data. The EVM is a crucial component of the Ethereum platform, as it enables developers to create decentralized applications (DApps) and deploy them on the blockchain.

Components of an EVM

Stack: The stack is a Last-In-First-Out (LIFO) data structure that stores operands for EVM instructions. The stack is used for performing arithmetic and logical operations on data.

Memory: The memory is a byte array that is used for storing temporary data during the execution of smart contracts. The size of the memory is dynamic and can be expanded or contracted as required.

Storage: The storage is a key-value store that is used for persistent storage of data between different smart contract invocations. Each smart contract has its own storage space, which is a mapping of 256-bit keys to 256-bit values.

Program Counter: The program counter is a register that keeps track of the current instruction being executed by the EVM.

Gas: Gas is a measure of computational effort required to execute an EVM instruction. Each instruction has a fixed gas cost associated with it, and executing a smart contract requires a certain amount of gas.

Call Data: Call data is the input data that is passed to a smart contract when it is invoked. The call data can be used to pass parameters and arguments to the smart contract.

These components work together to enable the execution of smart contracts on the Ethereum platform, while ensuring security, determinism, and consistency of the blockchain state.

Role of EVM

Smart Contract Execution: The EVM is responsible for executing the bytecode of smart contracts on the Ethereum blockchain. It ensures that the code is executed in a secure, deterministic, and consistent manner across all nodes on the network.

Gas Management: The EVM uses a gas mechanism to manage the resources required for executing smart contracts. Each EVM instruction has a gas cost associated with it, and the total gas used by a smart contract determines the fee paid to the network.

State Management: The EVM maintains the state of the Ethereum blockchain by storing account balances, contract storage, and other important data. The state is updated every time a smart contract is executed, ensuring that the blockchain remains consistent and tamper-proof.

Decentralized Applications: The EVM enables the development and deployment of decentralized applications (DApps) on the Ethereum platform. DApps can be written in a variety of programming languages, and can interact with the Ethereum blockchain through smart contracts.

What is Non-EVM?

In the context of Ethereum, “Non-EVM” usually refers to code or applications that are not executed on the Ethereum Virtual Machine (EVM).

For example, there are other blockchain platforms and smart contract environments that use different virtual machines for executing smart contracts. Some of the most popular non-EVM blockchain platforms include:

Polkadot: A blockchain platform that uses a custom-built virtual machine called Substrate. Substrate is designed to be modular, allowing developers to build custom blockchain applications with ease.

Cardano: A blockchain platform that uses the Plutus programming language and a custom-built virtual machine called the Cardano Virtual Machine (CVM) for executing smart contracts.

Binance Smart Chain: A blockchain platform that uses the BEP-20 token standard and a modified version of the Ethereum Virtual Machine (EVM) called the Binance Smart Chain Virtual Machine (BSC VM).

It is also possible to build decentralized applications that do not rely on blockchain technology at all. For example, some DApps use centralized servers and databases to store and process data, while using blockchain technology only for verification and validation purposes.

--

--