1/5
_Follow along with this video:_ --- In the previous lesson we got a glimpse of a contract's `bytecode`. When interacting with any smart contract, whether during its creation or subsequent transactions, there's an essential component at play—`call data`. It's the raw bytes or raw data that you're sending to the blockchain. ### What Exactly Is Call Data? Call data is the string of information that you send alongside a transaction to instruct the smart contract on the blockchain. It's similar to input parameters passed to a function in traditional programming, telling the smart contract what action you want it to take. Let's visualize this - pull up any transaction in Etherscan and scroll to the bottom. You should see a bunch of hex data. Each byte, which corresponds to two hex characters, essentially represents an opcode—or operational code—that the Ethereum Virtual Machine (EVM) recognizes (there are some exceptions, but we'll talk about that later!). Opcodes are the machine-readable instructions that detail how the EVM should manipulate data. ### Understanding Opcodes As humans, we're not wired to effortlessly comprehend machine-code or binary. Manually instructing thousands of transitors is just not something we're good at. Because of this, we turn to higher-level programming languages like Solidity that are easier for humans to understand! However, it's crucial to remember that the EVM doesn't understand Solidity; it operates at the lowest level of code. It's a machine that needs explicit instructions to work with data, whether storing it, memorizing it, or stacking it. These instructions are the aforementioned op codes. ### The Ethereum Virtual Machine The Ethereum Virtual Machine is, put simply, a state machine that emulates the computational environment of the Ethereum network on your own computer. When you hear about sending data to the blockchain or transacting Ethereum, picture the EVM diligently converting those tasks into smaller, machine-executable instructions—op codes. For example, if we're instructing our contract to store the number seven at a particular storage location, a specific sequence of op codes will facilitate that operation. It's this collection of op codes that embodies the EVM—a universally accepted set of commands that carry out predefined activities. > _Don't stress too much about not grasping it straight away, it is complex stuff._ ### Diving Into Code Examples To illustrate further, each pair of hex digits in the smart contract reflects a single opcode. But there are instances, such as when larger values are 'pushed' onto the stack, that the pattern alters a bit. Regardless, the crux is that these opcodes—whether signifying `PUSH1` or `MSTORE` (for memory storage)—orchestrate the execution of call data instructions. ### The Evolution of Opcodes The beauty of Ethereum is its adaptability. Opcodes aren't set in stone; they evolve through Ethereum Improvement Proposals (EIPs). Recently, a new opcode, `PUSH0`, made its debut, expanding the EVM's vocabulary. Remember, the essence of a smart contract is the synergy of opcodes composing executable contract code—each opcode taking a transformative journey from a mere hex digit to a commanding force in the blockchain realm. Don't be overwhelmed if opcodes seem alien today. Like most things in the tech world, it's all about layering knowledge, one byte at a time.
A comprehensive overview of opcodes, which are machine-readable instructions, as used in Ethereum. The lesson covers the basics of opcodes, their role in the Ethereum Virtual Machine (EVM), and how they are used to execute smart contracts.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on November 15, 2024
Solidity Developer
Assembly and Formal VerificationDuration: 30min
Duration: 4h 38min
Duration: 3h 57min
Duration: 1h 56min
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on November 15, 2024
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar