Your First Bytecode Execution
This guide will walk you through executing your first EVM bytecode using Cubipods.Execute a simple addition
Let’s start with a basic arithmetic operation - adding two numbers:What this does:
60 03- PUSH1 0x03 (pushes 3 onto the stack)60 02- PUSH1 0x02 (pushes 2 onto the stack)01- ADD (pops the top two values, adds them, pushes result)
0x05 on the stack.The
-b flag is short for --bytecode. Both forms are supported.Enable verbose mode
To see what’s happening during execution, add the This displays detailed execution history including:
-v (verbose) flag:- Each opcode executed
- Stack state changes
- Memory modifications
- Storage operations
Common Operations
Here are some common bytecode patterns you can try:Working with Memory
Cubipods supports EVM memory operations:60 20- PUSH1 0x20 (value to store: 32)60 80- PUSH1 0x80 (memory location: 128)52- MSTORE (stores value at memory location)
Working with Storage
Storage operations persist data in slots:64 68656c6c6f- PUSH5 0x68656c6c6f (“hello” in hex)60 01- PUSH1 0x01 (storage slot 1)55- SSTORE (stores value in slot)
Stack Operations
Cryptographic Operations
Cubipods supports the KECCAK256 opcode:64 68656c6c6f- PUSH5 0x68656c6c6f (“hello” in hex)20- KECCAK256 (hashes the value)
0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
Command-Line Options
Cubipods supports the following CLI options:| Option | Short | Description |
|---|---|---|
--bytecode <BYTECODE> | -b | Bytecode consisting of EVM opcodes to execute (required) |
--verbose | -v | Enable verbose mode with execution history and state output |
--version | Display the version number | |
--help | -h | Display help information |
Understanding Verbose Output
When you run with-v, Cubipods shows:
- Execution History: Each opcode executed in sequence
- Stack Changes: How each operation modifies the stack
- Memory State: Memory locations and their values
- Storage State: Storage slots and their values
Tips for Writing Bytecode
Omit 0x prefix
You can write bytecode with or without the
0x prefix:cubipods -b 6001✓cubipods -b 0x6001✓
Use verbose mode
Always use
-v when debugging or learning - it shows exactly what’s happeningStart simple
Begin with simple operations like PUSH and ADD, then build up to more complex bytecode
Check the stack
Remember the EVM is a stack machine - operations pop from and push to the stack
Next Steps
Now that you’ve executed your first bytecode, explore more advanced topics:CLI Reference
Complete reference for all command-line options
Supported Opcodes
Full list of supported EVM opcodes and their behavior
Core Concepts
Understand stack, memory, and storage in depth
Examples
More complex bytecode examples and use cases