Skip to main content

Your First Bytecode Execution

This guide will walk you through executing your first EVM bytecode using Cubipods.
1

Execute a simple addition

Let’s start with a basic arithmetic operation - adding two numbers:
cubipods -b 6003600201
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)
The bytecode executes successfully, leaving 0x05 on the stack.
The -b flag is short for --bytecode. Both forms are supported.
2

Enable verbose mode

To see what’s happening during execution, add the -v (verbose) flag:
cubipods -b 6003600201 -v
This displays detailed execution history including:
  • Each opcode executed
  • Stack state changes
  • Memory modifications
  • Storage operations
Verbose mode is invaluable for debugging and understanding how opcodes modify EVM state.
3

Try more complex operations

Now let’s try a more complex example with multiple operations:
cubipods -b 6020600a60140101 -v
Breakdown:
  • 60 20 - PUSH1 0x20 (pushes 32)
  • 60 0a - PUSH1 0x0a (pushes 10)
  • 60 14 - PUSH1 0x14 (pushes 20)
  • 01 - ADD (10 + 20 = 30)
  • 01 - ADD (32 + 30 = 62, which is 0x3e in hex)
Final stack contains: 0x3e

Common Operations

Here are some common bytecode patterns you can try:
# 10 * 20 = 200 (0xc8)
cubipods -b 6014600a02

Working with Memory

Cubipods supports EVM memory operations:
# Store 0x20 (32) at memory location 0x80
cubipods -b 6020608052 -v
Breakdown:
  • 60 20 - PUSH1 0x20 (value to store: 32)
  • 60 80 - PUSH1 0x80 (memory location: 128)
  • 52 - MSTORE (stores value at memory location)
With verbose mode, you’ll see the memory state after execution.

Working with Storage

Storage operations persist data in slots:
# Store "hello" (0x68656c6c6f) in storage slot 1
cubipods -b 6468656c6c6f600155 -v
Breakdown:
  • 64 68656c6c6f - PUSH5 0x68656c6c6f (“hello” in hex)
  • 60 01 - PUSH1 0x01 (storage slot 1)
  • 55 - SSTORE (stores value in slot)
Verbose mode shows the storage slot and value.

Stack Operations

# Duplicate the top stack item
cubipods -b 600180 -v
# PUSH1 0x01, DUP1

Cryptographic Operations

Cubipods supports the KECCAK256 opcode:
# Hash the word "hello"
cubipods -b 6468656c6c6f20 -v
Breakdown:
  • 64 68656c6c6f - PUSH5 0x68656c6c6f (“hello” in hex)
  • 20 - KECCAK256 (hashes the value)
Result: 0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
You can verify this hash using the command: cast keccak hello

Command-Line Options

Cubipods supports the following CLI options:
OptionShortDescription
--bytecode <BYTECODE>-bBytecode consisting of EVM opcodes to execute (required)
--verbose-vEnable verbose mode with execution history and state output
--versionDisplay the version number
--help-hDisplay help information

Understanding Verbose Output

When you run with -v, Cubipods shows:
  1. Execution History: Each opcode executed in sequence
  2. Stack Changes: How each operation modifies the stack
  3. Memory State: Memory locations and their values
  4. Storage State: Storage slots and their values
This makes it easy to understand exactly how your bytecode executes.
Bytecode without a STOP (0x00) opcode will execute until all opcodes are processed. Malformed bytecode may result in errors.

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 happening

Start 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

Build docs developers (and LLMs) love