Wiki/EVM Opcodes: An Introduction to Ethereum's Bytecode
EVM Opcodes: An Introduction to Ethereum's Bytecode - Biturai Wiki Knowledge
ADVANCED | BITURAI KNOWLEDGE

EVM Opcodes: An Introduction to Ethereum's Bytecode

EVM Opcodes are the fundamental, low-level instructions that power smart contracts on the Ethereum blockchain. They represent the compiled binary format of Solidity code, dictating how the Ethereum Virtual Machine executes operations.

Biturai Knowledge
Biturai Knowledge
Research library
Updated: 6/26/2026
Technically checked

Structure, readability, internal linking, and SEO metadata were automatically checked. This article is continuously updated and is educational content, not financial advice.

Definition

EVM Opcodes (Operation Codes) are the elementary, low-level machine instructions that define how the Ethereum Virtual Machine (EVM) executes smart contracts. They constitute the bytecode, which is the compiled binary format of high-level programming languages like Solidity or Vyper, deployed onto the Ethereum blockchain.

At its core, the Ethereum Virtual Machine is a stack-based, big-endian virtual machine with a word size of 256 bits. Opcodes are the language this virtual machine understands, similar to how a computer's central processing unit (CPU) executes machine code instructions. Every action a smart contract performs, from simple arithmetic to complex state changes, is ultimately broken down into a sequence of these opcodes.

Key Takeaway

EVM Opcodes are the foundational "DNA" of smart contracts, ensuring the deterministic execution of code across the entire Ethereum network. This means that every node in the network processing a transaction will arrive at precisely the same outcome, as they all interpret the same low-level instructions. This consistency is vital for the integrity and security of the blockchain, guaranteeing that the network's state remains synchronized and smart contracts function as intended, regardless of which node executes them. The predictable nature of opcode execution is a cornerstone of Ethereum's reliability and trustless environment.

Mechanics

The Ethereum Virtual Machine operates as a stack-based machine. This means that most opcodes retrieve their operands from the stack, perform an operation, and then place the result back onto the stack. The stack is a temporary memory area that functions on a Last-In, First-Out (LIFO) principle. In addition to the stack, opcodes also interact with memory (a volatile, expandable storage area for runtime data) and storage (the persistent storage of a smart contract, which is saved on the blockchain).

Each opcode has a specific function and is associated with gas costs. These costs reflect the computational complexity and resource consumption of the respective operation. For example, the ADD opcode incurs a small amount of gas, while more complex operations like writing to persistent storage (SSTORE) incur significantly higher costs. The gas system is an integral part of Ethereum, designed to protect the network from spam and incentivize developers to create efficient code. If a transaction does not provide enough gas, it will fail, but the gas already consumed will not be refunded. Opcodes can be categorized into various groups, including arithmetic operations (ADD, MUL, DIV), stack manipulation (PUSH, POP, DUP, SWAP), memory and storage operations (MLOAD, MSTORE, SLOAD, SSTORE), control flow (JUMP, JUMPI), logic (AND, OR, XOR), cryptography (SHA3), and environment queries. The latter allow the contract to retrieve information about the current execution environment, such as the size of input data (CALLDATASIZE), the size of the current contract's code (CODESIZE), the size of an external account's code (EXTCODESIZE), the size of return data (RETURNDATASIZE), or the amount of available gas (GAS). This diversity of opcodes enables the implementation of complex logic within smart contracts.

Trading Relevance

For traders navigating the crypto market, a direct understanding of EVM opcodes is generally not required to make trading decisions. However, a fundamental awareness of their existence and function can have indirect implications for trading. Understanding that smart contracts are executed at a very low level helps appreciate the deterministic nature and security aspects of the blockchain. This can strengthen confidence in decentralized applications (dApps) and DeFi protocols, whose underlying logic is defined by these opcodes.

A deeper understanding of the opcode level is particularly relevant when it comes to gas optimization of smart contracts. Developers who write efficient bytecode can reduce transaction costs for users. Lower fees can increase a protocol's attractiveness and lead to broader adoption, which in turn can positively impact the value of associated tokens. Traders evaluating the technical efficiency of a project might indirectly benefit from this knowledge by favoring projects with well-optimized contracts. Furthermore, bytecode analysis is essential for security audits of smart contracts. Vulnerabilities at the opcode level can lead to exploits that massively affect the value of tokens or the stability of a protocol. Traders who inform themselves about the quality of audits can thus develop a better understanding of risk.

Risks

The low-level nature of EVM opcodes carries specific risks relevant to developers, and indirectly, to users and traders. One of the biggest risks is bugs in the bytecode. Even a seemingly minor error in the opcode sequence can lead to severe vulnerabilities, such as reentrancy attacks, integer overflows, or incorrect access permissions. Such vulnerabilities can be exploited by attackers to drain funds from smart contracts, leading to significant financial losses for users and a loss of trust in the affected protocol. The complexity of bytecode makes manual verification difficult and requires specialized tools and expertise for effective audits.

Another risk is gas limit exhaustion. Inefficiently written bytecode that uses too many or too expensive opcodes can cause a transaction to reach the maximum gas limit before it completes. In this case, the transaction fails, but the gas already consumed is still paid by the sender. This leads to unnecessary costs and a poor user experience. For traders, this means that transactions interacting with poorly optimized contracts can be more expensive and less reliable. Additionally, changes in opcode behavior through Ethereum Improvement Proposals (EIPs) can introduce new upgrade risks. If existing contracts are not carefully checked for compatibility with new opcode definitions, subtle errors can arise, causing unforeseen behavior or security vulnerabilities.

History and Examples

EVM opcodes have been an integral part of the network since Ethereum's inception. They were designed from the outset as the fundamental execution layer for smart contracts. The formal specification of the EVM and its opcodes is detailed in the Ethereum Yellow Paper by Gavin Wood, a technical document that precisely defines the architecture and behavior of the Ethereum blockchain. This document serves as a reference for all Ethereum client implementations, ensuring that the EVM functions consistently on every node.

Over time, the set of EVM opcodes has evolved through Ethereum Improvement Proposals (EIPs). New opcodes are introduced to expand the EVM's functionality, improve efficiency, or enable new use cases. An example of this is the introduction of the RETURNDATASIZE opcode (EIP 211), which allows smart contracts to query the size of return data from an external call. This was an important addition to enable more flexible and secure interactions between contracts. Some of the most common and fundamental opcodes include:

  • PUSH: Places a value onto the stack.
  • ADD, SUB, MUL, DIV: Perform basic arithmetic operations.
  • SLOAD, SSTORE: Load values from or store them into persistent contract storage.
  • CALL, DELEGATECALL: Enable interaction with other smart contracts.
  • JUMP, JUMPI: Control program flow based on conditions.
  • GAS: Retrieves the amount of currently available gas.
  • CODESIZE, EXTCODESIZE, CALLDATASIZE: Provide information about the size of code or input data.

These opcodes form the vocabulary with which the complex operations of smart contracts are expressed on the Ethereum blockchain.

Common Misunderstandings

A widespread misunderstanding is that opcodes are the same as Solidity. This is incorrect. Solidity is a high-level language that is more human-readable and simplifies the development of smart contracts. However, before a Solidity contract can be deployed on the Ethereum blockchain, it must be translated by a compiler into EVM bytecode, which consists of a sequence of opcodes. Opcodes are the machine language of the EVM, while Solidity represents an abstraction layer above it. One can compare it to the difference between C++ and the assembly code into which C++ is compiled.

Another misunderstanding is that opcodes are only relevant for developers. While developers directly work with optimizing and understanding bytecode, opcodes have indirect effects on all users of the Ethereum network. The efficiency and security of smart contracts, determined by the underlying opcodes, influence gas costs, transaction speeds, and susceptibility to attacks. Therefore, a basic understanding of the role of opcodes is beneficial for anyone seriously engaging with Ethereum and its applications, even if they are not programming themselves.

Furthermore, it is often assumed that all gas costs are static. Although many opcodes have fixed base costs, the costs for certain operations vary significantly. A prominent example is the SSTORE opcode, whose gas costs depend on whether a storage slot is set from zero to a value (expensive), from a value to zero (cheaper, with gas refund), or changed from one value to another. These dynamic costs are a mechanism to regulate the use of the valuable persistent blockchain storage and incentivize efficient storage management. Finally, the EVM is not a physical machine, but an abstract specification implemented by every Ethereum client. It does not exist as a single piece of hardware but as a logical environment executed collectively by all participants in the network.

Summary

EVM opcodes are the fundamental building blocks that form the heart of the Ethereum Virtual Machine and enable the execution of smart contracts on the blockchain. They represent the machine-level language into which higher-level programming languages like Solidity are compiled, to be deterministically executed by every node in the Ethereum network. While a direct understanding of them is not necessary for most users, their functionality is crucial for the security, efficiency, and overall integrity of the Ethereum ecosystem.

The gas costs associated with each opcode govern resource allocation and prevent misuse, while the diversity of opcodes allows for the implementation of complex logic. Risks such as bytecode bugs and gas limit exhaustion underscore the necessity of careful development and audits. Ultimately, EVM opcodes are the invisible yet indispensable foundation upon which the entire world of decentralized applications and DeFi on Ethereum is built.

OKX · Official Biturai Partner

OKX

Explore the current OKX offering through the official Biturai partner link. Products and availability may vary by country.

Explore OKX

Partner link · Biturai may receive compensation when it is used · not investment advice

OKX

Disclaimer

This article is for informational purposes only. The content does not constitute financial advice, investment recommendation, or solicitation to buy or sell securities or cryptocurrencies. Biturai assumes no liability for the accuracy, completeness, or timeliness of the information. Investment decisions should always be made based on your own research and considering your personal financial situation.

Transparency

Biturai may use AI-assisted tools to research, structure, or update Wiki articles. Editorially reviewed articles are marked separately; all content remains educational and does not replace your own review.