Crypto glossary

Opcode (EVM opcodes)

Definition

An opcode is a single low-level instruction, such as ADD, SSTORE or CALL, that the EVM or another virtual machine executes at a set gas cost.

Smart contracts written in Solidity or Vyper are compiled into bytecode, a sequence of one-byte opcodes plus their data. The Ethereum Virtual Machine reads them one by one on a stack: PUSH places values, ADD and MUL do arithmetic, SLOAD and SSTORE read and write permanent storage, CALL and DELEGATECALL invoke other contracts, and LOG emits events. Bitcoin Script uses opcodes too, in a far more limited set.

Opcodes matter because gas is priced per instruction. Writing to storage is among the most expensive, which is why developers optimise contracts around it. Network upgrades often change the instruction set: PUSH0 arrived with Shanghai, transient storage (TSTORE and TLOAD) and MCOPY with Dencun, and gas repricings have adjusted opcodes that were too cheap for the work they caused.

Opcode behaviour is a frequent source of security issues. SELFDESTRUCT was restricted in 2024 because of its side effects, and EVM-compatible chains do not always implement every opcode identically, so code that works on Ethereum can behave differently on another network. Auditors read opcode traces when source code is unavailable.

Example

A developer cuts the gas cost of a token transfer by caching a value in memory instead of calling SLOAD on the same storage slot three times.

Related terms

Latest articles on Opcode