Skip links

Table of Contents

What is an Ethereum Virtual Machine (EVM) and How It Works? (Updated)

What is a Virtual Machine (VM)?

A virtual machine (VM) is a software program that creates a virtual computer within your physical computer. This virtual computer can run its own operating system and software, and it is isolated from the rest of your computer. This makes VMs useful for a variety of purposes, such as:

  • Running multiple operating systems on the same computer
  • Testing software in a safe environment
  • Isolating malware from the rest of your computer

What is The Ethereum Virtual Machine Definition?

The Ethereum Virtual Machine (EVM) is a special type of VM that is used to run smart contracts and decentralized applications (DApps) on the Ethereum blockchain.

In other words, EVM, is a Turing-complete machine, which means that it can theoretically execute any program. However, the EVM is also limited by the amount of gas that is available for each transaction. Gas is a unit of measurement that is used to track the computational resources used by each operation.

Knowledge Perks:

Smart contracts are self-executing agreements that are stored on the blockchain. They can be used to automate a wide variety of tasks, such as:

  • Transferring money between accounts
  • Creating tokens
  • Managing ownership of assets

Step-by-Step: How the Ethereum Virtual Machine (EVM) Works

Step 1: A smart contract is written in a high-level language

A developer writes the contract using a language such as Solidity or Vyper. This code contains functions, logic, variables, and business rules.

Step 2: The contract is compiled into EVM bytecode

The Solidity compiler (solc) takes the high-level code and translates it into:

  • EVM bytecode, which the EVM can execute.
  • An ABI (Application Binary Interface), which defines how external callers interact with the contract.

The bytecode is a long sequence of low-level instructions made up of opcodes.

Step 3: The contract is deployed to the blockchain

A deployment transaction is created with:

  • The to field set to empty (because a new contract is being created).
  • The data field containing the compiled contract bytecode.

Miners or validators include this transaction in a block. The EVM executes the deployment code one time. If it completes successfully, Ethereum stores the contract’s runtime bytecode at a new contract address in the global state.

Step 4: A user sends a transaction to call the contract

When a user wants to interact with the contract:

  • They send a transaction to the contract’s address.
  • The data field contains the encoded function name and arguments.
  • A gas limit and gas price are included.

This transaction is broadcast to the network and picked up by nodes.

Step 5: The EVM sets up an isolated execution environment

For each transaction, the EVM creates a clean execution sandbox that includes:

  • A stack (LIFO, maximum depth 1024) for temporary values.
  • Memory, which is temporary and cleared after execution.
  • Storage, which is persistent and holds the contract’s long-term variables.
  • A program counter (PC) indicating the current instruction.
  • A gas counter tracking how much gas remains.

The execution environment cannot interact with the outside world directly.

Step 6: The EVM begins reading and executing opcodes

The bytecode is a series of single-byte opcodes. The EVM reads them one by one and executes the corresponding instruction.

Example: To add two numbers, the following assembly could be produced:

PUSH1 0x02
PUSH1 0x03
ADD

Hex representation:

0x60 0x02 0x60 0x03 0x01

Execution sequence:

  1. PUSH1 0x02 places the value 2 on the stack.
  2. PUSH1 0x03 places the value 3 on the stack.
  3. ADD pops both values, computes 2 + 3 = 5, and pushes 5 onto the stack.

Every smart contract function ultimately executes as a series of these low-level stack operations.

Step 7: Gas is consumed during execution

Each opcode has a fixed gas cost. Before executing an instruction, the EVM checks whether enough gas is available.

If gas runs out:

  • The EVM stops execution immediately.
  • All state changes revert.
  • The gas already consumed is not refunded.

Gas ensures the network remains secure and prevents denial-of-service or infinite-loop attacks.

Step 8: The EVM updates the global Ethereum state

If execution completes successfully:

  • Storage changes are written permanently.
  • Ether balances may be updated.
  • Events (logs) are emitted.
  • Unused gas is partially refunded to the sender.

If execution fails or reverts:

  • All state changes are discarded.
  • The transaction is still recorded on-chain.
  • The spent gas is still charged.

Step 9: Every node repeats this process identically

Every Ethereum node independently executes the same bytecode with the same inputs. Because the EVM is deterministic, all nodes should arrive at the same result. This ensures the entire network agrees on the correct global state.

Step 10: Connecting this process to the Ethereum State Transition Function

All of the steps above can be summarized in Ethereum’s formal state transition function. It describes how a transaction transforms the blockchain’s global state:

σ + T → σ’

Where:

  • σ is the current global state.
  • T is the transaction.
  • σ’ is the new state produced by running the EVM.

This is the mathematical foundation that keeps Ethereum in consensus.

OpcodeHex CodeDescription
ADD0x01Binary operation that adds the top two items from the stack and pushes the result back onto the stack.
MUL0x02Binary operation that multiplies the top two stack items and pushes the result back onto the stack.
SUB0x03Binary operation that subtracts the second stack item from the first (top two items on the stack) and pushes the result back onto the stack.
DIV0x04Binary operation that divides the first stack item by the second and pushes the quotient back onto the stack. If it is a division by zero, it pushes zero.
JUMP0x56Unconditional jump operation that replaces the program counter with the top item from the stack. The next opcode is taken from that position in the code.
JUMPI0x57Conditional jump operation that takes two arguments from the stack. If the first item is non-zero, it sets the program counter to the value of the second item. Otherwise, no effect.
PUSH1, PUSH320x60 – 0x7fPlaces 1 to 32 bytes item on stack. For instance, PUSH1 might place a single byte onto the stack, while PUSH32 would place 32 bytes onto the stack.
CALL0xf1Executes a new message call and sends the output data from the executed contract back to the current one. It takes seven arguments from the stack.
EVM opcodes examples

The EVM will continue to execute bytecodes in this way until the entire smart contract has been executed. The EVM is a complex piece of software, but it is essential to the functioning of the Ethereum network. It allows Ethereum to be a platform for decentralized applications, and it is responsible for ensuring that the Ethereum network is secure and reliable.

Now that we have gained some insights into the execution of bytecode by the EVM, let’s proceed to grasp the concept of the Ethereum state transition function.

The Ethereum State Transition Function

The Ethereum State Transition Function (STF) defines how every transaction changes the global state of the Ethereum blockchain. It takes the current state and a transaction as inputs, executes that transaction through the Ethereum Virtual Machine (EVM), and produces a new state as output. This formal rule is what ensures that all nodes, running the same transaction, reach the same result.

We can write it as:

STF(S, T) = S’

Where:

  • S is the current global state of the blockchain.
  • T is the transaction being executed.
  • S’ is the new global state after the transaction has been processed.

Every Ethereum node independently applies the State Transition Function to each transaction in the same order. Because the EVM is deterministic, every honest node computes the same S’. This is how Ethereum maintains a single shared version of truth across the network, and it is a fundamental piece of how the platform can securely support decentralized applications.

Ethereum Virtual Machine Definition evm
A diagram of the Ethereum Virtual Machine (EVM). This would help to illustrate how it works and how it is connected to the Ethereum blockchain.

What are the Benefits and Drawbacks of the EVM?

BenefitsDrawbacks
Versatile and Programmable:
Enables complex decentralized applications and smart contracts with various functionalities.
Gas Limitations:
The gas mechanism can restrict the execution of resource-intensive tasks, making some operations costly.
Decentralization:Operates on a decentralized blockchain network, ensuring trust and transparency.Security Risks:Vulnerabilities in smart contracts and coding errors can lead to security breaches and financial losses.
Transparency and Auditing:All transactions and smart contract executions are publicly recorded, enabling easy auditing and verification.Scalability Challenges:As the network grows, the EVM’s scalability may become a challenge, leading to slower transaction processing.
Interoperability:Allows integration with other blockchains and protocols, promoting cross-chain interactions.Upgrade and Fork Compatibility:Hard forks or upgrades may introduce incompatibility with older versions of smart contracts, creating disruptions.
Benefits and drawbacks of EVM

How to use EVM safely and securely?

Here are some additional tips for using the EVM safely and securely:

  • Use a secure programming language: Solidity is a popular and well-respected programming language for creating smart contracts. It is designed to be secure and resistant to attack.
  • Review the code of the EVM before using it: It is open source, which means that you can review its code before using it. This will help you to understand how it works and to identify any potential security risks.
  • Stay up-to-date with the latest EVM updates and security best practices: The EVM is constantly being updated with new features and security improvements. It is important to stay up-to-date with these changes so that you can use it safely.
  • Use gas-efficient code: Gas fees are used to pay for the computational resources used by each transaction. Gas fees can be expensive, so it is important to use gas-efficient code when creating smart contracts.
  • Use safe coding practices: There are a number of safe coding practices that can help to mitigate security risks. These practices include using secure functions, avoiding reentrancy attacks, and testing your smart contracts thoroughly before deploying them.
  • Use a security audit: If you are creating a complex smart contract, you may want to consider having it audited by a security expert. This can help to identify any potential security risks before they are exploited.

By following these tips, you can help to ensure that your use of the EVM is safe and secure.

What are some examples of how the EVM is being used in real-world applications?

  • Decentralized finance (DeFi): DeFi is a rapidly growing ecosystem of financial applications that are built on top of the Ethereum blockchain. These applications allow users to lend, borrow, and trade assets without the need for a central authority. Some of the most popular DeFi applications include MakerDAO, Compound, and Uniswap.
  • Non-fungible tokens (NFTs): NFTs are a type of digital asset that is unique and cannot be replaced. They are often used to represent ownership of digital artworks, collectibles, and other items. Some of the most popular NFT platforms include OpenSea, Rarible, and Foundation.
  • Gaming: The EVM is also being used to power a new generation of decentralized games. These games are built on top of the Ethereum blockchain and allow players to own their in-game assets. Some of the most popular decentralized games include Axie Infinity, The Sandbox, and Gods Unchained.
  • Supply chain management: The EVM can also be used to improve the efficiency and transparency of supply chain management. For example, it can be used to track the movement of goods and to verify the authenticity of products. Some of the companies that are using the EVM for supply chain management include Walmart, IBM, and SAP.

These are just a few examples of how the EVM is being used in real-world applications. As the EVM continues to evolve, it is likely to be used in even more innovative and creative ways.

What are Future Developments and Upgrades of the EVM?

The Ethereum Virtual Machine (EVM) is constantly evolving, and there are a number of future developments and updates that are being planned. Some of the most notable include:

EVM Opcodes

The EVM is becoming more efficient with new opcodes that make smart contracts faster and cheaper.

Fusaka (Dec 2025):

  • Adds CLZ (Count Leading Zeros) via EIP-7939 for better bit manipulation and lower gas use.
  • EIP-7823 improves crypto verification so all clients behave consistently.

Read here to know what fusaka is and get updated!

2026 & Beyond:

  • Glamsterdam introduces Block-level Access Lists (BALs) for more accurate gas tracking.
  • The roadmap includes major ZK-EVM improvements, potentially adding new privacy-focused opcodes.

In short: Developers get more flexibility and better performance.

EVM Gas Fees

Gas fees still reflect computation, but upgrades are making them more predictable and cheaper.

Fusaka (Dec 2025):

  • Raises the block gas limit from ~45M to 60M.
  • Caps individual transactions at 16.7M gas to reduce DoS risk.
  • EIP-7883 updates ModExp costs, and EIP-7918 reduces L2 blob posting fees.

2026 Outlook:

  • ePBS in Glamsterdam improves block construction, indirectly lowering gas.
  • More gas repricing and slot optimizations aim to increase throughput safely.

Goal: Lower average fees by ~50% during high traffic while L2s scale toward 100k+ TPS.

EVM Security

Security upgrades focus on stronger cryptography and better protection against attacks.

Fusaka (Dec 2025):

  • Adds secp256r1 support (EIP-7951), improving compatibility with Web2 and other chains.
  • Strengthens DoS protections (EIP-7934).
  • EIP-7823 standardizes crypto behavior across clients.

2026 & Beyond:

  • Better validator efficiency to support decentralization.
  • Research into quantum-resistant signatures, formal verification, and privacy-preserving state reads.

End result: A more secure and future-proof EVM.

EVM Scalability

Scalability efforts focus on L2 performance, data availability, and modularity.

Fusaka (Dec 2025):

  • Introduces PeerDAS (EIP-7594) so light nodes can verify L2 data faster.
  • Increases blob capacity (from 3 → up to 9).
  • Adds BPO Forks (EIP-7892) to allow quick L2 scaling changes.

2026 Outlook:

  • Glamsterdam enshrines ePBS and brings in BALs to optimize state access.
  • Priorities include cross-L2 interoperability, faster proof aggregation, and Stage 2 rollups targeting sub-second finality.

Summary: Ethereum becomes faster, more modular, and better suited for large-scale adoption.

Final Thoughts

You now have a deeper understanding of what is an EVM (Ethereum Virtual Machine) is and how it works. Have any further questions, ideas to share, or perhaps want to showcase what you’ve learned? Feel free to reach out to us via Twitter.

Frequently asked questions

What is the Ethereum Virtual Machine (EVM)?

  • The EVM is a runtime environment for smart contracts in Ethereum, completely isolated for security.

How does EVM work in the Ethereum platform?

  • EVM executes operations on every node in the network for consensus and correctness.

What is gas in the context of the EVM?

  • Gas is the execution fee paid for transactions or smart contracts processing on Ethereum.

How is the EVM related to smart contracts?

  • EVM provides the environment to execute Ethereum smart contracts written in languages like Solidity.

What languages can you use to write smart contracts for the EVM?

  • Languages like Solidity, Serpent, LLL, and Vyper can be used for Ethereum smart contracts.

Can the EVM run applications beyond finance?

  • Yes, Ethereum’s architecture allows for diverse decentralized applications (DApps) including games, social networking, etc.

Are there alternatives to the EVM in the blockchain world?

  • Yes, platforms like Bitcoin and NEO have their own versions of a virtual machine.

Do all Ethereum nodes run an EVM?

  • Yes, all full nodes on the Ethereum network run an EVM instance for consensus.

What is Ethereum 2.0 and how does it impact the EVM?

  • Ethereum 2.0, or Eth2, is an upgrade aiming to increase transaction speed and efficiency, potentially affecting the EVM.

Can smart contracts be executed on other virtual machines?

  • Yes, platforms like Neo, EOS, and Tron support smart contracts with their own virtual machines

Powered by Metana Editorial Team, our content explores technology, education and innovation. As a team, we strive to provide everything from step-by-step guides to thought provoking insights, so that our readers can gain impeccable knowledge on emerging trends and new skills to confidently build their career. While our articles cover a variety of topics, we are highly focused on Web3, Blockchain, Solidity, Full stack, AI and Cybersecurity. These articles are written, reviewed and thoroughly vetted by our team of subject matter experts, instructors and career coaches.

Metana Guarantees a Job 💼

Plus Risk Free 2-Week Refund Policy ✨

You’re guaranteed a new job in web3—or you’ll get a full tuition refund. We also offer a hassle-free two-week refund policy. If you’re not satisfied with your purchase for any reason, you can request a refund, no questions asked.

Web3 Solidity Bootcamp

The most advanced Solidity curriculum on the internet!

Full Stack Web3 Beginner Bootcamp

Learn foundational principles while gaining hands-on experience with Ethereum, DeFi, and Solidity.

You may also like

Metana Guarantees a Job 💼

Plus Risk Free 2-Week Refund Policy

You’re guaranteed a new job in web3—or you’ll get a full tuition refund. We also offer a hassle-free two-week refund policy. If you're not satisfied with your purchase for any reason, you can request a refund, no questions asked.

Web3 Solidity Bootcamp

The most advanced Solidity curriculum on the internet

Full Stack Web3 Beginner Bootcamp

Learn foundational principles while gaining hands-on experience with Ethereum, DeFi, and Solidity.

Events by Metana

Dive into the exciting world of Web3 with us as we explore cutting-edge technical topics, provide valuable insights into the job market landscape, and offer guidance on securing lucrative positions in Web3.

Subscribe to Lettercamp

We help you land your dream job! Subscribe to find out how

Get a detailed look at our Cyber Security Bootcamp

Understand the goal of the bootcamp

Find out more about the course

Explore our methodology & what technologies we teach

You are downloading 2025 updated Cyber Security Bootcamp syllabus!

Download the syllabus to discover our Cyber Security Bootcamp curriculum, including key modules, project-based learning details, skill outcomes, and career support. Get a clear path to becoming a top developer.

Cyber Security Bootcamp Syllabus Download

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Get a detailed look at our AI Automations Bootcamp

Understand the goal of the bootcamp

Find out more about the course

Explore our methodology & what technologies we teach

You are downloading 2025 updated AI Automations Bootcamp syllabus!

Download the syllabus to discover our AI Automations Bootcamp curriculum, including key modules, project-based learning details, skill outcomes, and career support. Get a clear path to becoming a top developer.

AI Automations Bootcamp Syllabus Download

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Get a detailed look at our Software Engineering Bootcamp

Understand the goal of the bootcamp

Find out more about the course

Explore our methodology & what technologies we teach

You are downloading 2025 updated Software Engineering Bootcamp syllabus!

Download the syllabus to discover our Software Engineering Bootcamp curriculum, including key modules, project-based learning details, skill outcomes, and career support. Get a clear path to becoming a top developer.

Software Engineering Bootcamp Syllabus Download

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Santa saved a gift for you
Get 20% off to Change Your Career

Days
Hours
Minutes
Seconds

New Application Alert!

A user just applied for Metana Web3 Solidity Bootcamp. Start your application here : metana.io/apply

Get a detailed look at our Full Stack Bootcamp

Understand the goal of the bootcamp

Find out more about the course

Explore our methodology & what technologies we teach

You are downloading 2025 updated Full stack Bootcamp syllabus!

Download the syllabus to discover our Full-Stack Software Engineering Bootcamp curriculum, including key modules, project-based learning details, skill outcomes, and career support. Get a clear path to becoming a top developer.

Software Engineering Syllabus Download

"*" indicates required fields

This field is for validation purposes and should be left unchanged.