For the complete documentation index, see llms.txt. This page is also available as Markdown.

run

Run raw EVM bytecode in call or create mode with full environment control.

Execute arbitrary EVM bytecode in a controlled local environment.

Usage

mega-evme run [OPTIONS] [CODE]

CODE is the bytecode to execute, given as a 0x-prefixed hex string. You can also supply bytecode from a file with --codefile. Exactly one of these two inputs must be provided.

Code Input

Argument
Description

CODE

EVM bytecode as a 0x-prefixed hex string (positional)

--codefile <PATH>

Path to a file containing bytecode. Use - to read from stdin.

Execution Modes

Call Mode (default)

By default, run operates in call mode. Before execution, the bytecode is deployed at the receiver address (default: 0x0000000000000000000000000000000000000000). The transaction is then a CALL to that address. Input data supplied via --input or --inputfile is passed as calldata.

Use --receiver to target a specific address, or rely on the default zero address for simple bytecode tests.

Create Mode (--create)

Pass --create true to treat the bytecode as init code. Any input data supplied via --input or --inputfile is appended to the init code before execution, allowing you to pass constructor arguments. On success, the output is the deployed contract's runtime bytecode, and the tool prints the resulting contract address.

In create mode, --receiver must not be set.

Options

run accepts several groups of shared options. Each group is documented on its own page.

Group
Flags
Reference

Transaction

--create, --gas, --basefee, --priority-fee, --tx-type, --value, --sender, --receiver, --nonce, --input, --inputfile, --source-hash, --mint, --auth, --access

Transaction Types

State management

--prestate, --sender.balance, --faucet, --balance, --storage, --block-hash, --fork, --fork.block, --rpc, --dump, --dump.output

State Management

Chain and spec

--spec, --chain-id

Chain and Spec

Block environment

--block.number, --block.coinbase, --block.timestamp, --block.gaslimit, --block.basefee, --block.difficulty, --block.prevrandao, --block.blobexcessgas

Block Environment

SALT buckets

--bucket-capacity

SALT Buckets

RPC cache / retry

--rpc.cache-size, --rpc.cache-dir, --rpc.no-cache-file, --rpc.clear-cache, --rpc.max-retries, --rpc.backoff-ms, --rpc.rate-limit

RPC Cache and Retry

Tracing

--trace, --tracer, --trace.output, and tracer-specific flags

Tracing Overview

Output

--json

See JSON output below

Key defaults for run:

Option
Default

--spec

Rex7

--gas

10000000

--sender

0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

--receiver

0x0000000000000000000000000000000000000000

JSON Output

Pass --json to emit a single ExecutionSummary JSON object to stdout instead of the human-readable banner. No banners or diagnostic text are printed in JSON mode — stdout contains exactly one JSON object.

The object includes these fields:

Field
Type
Description

success

bool

Whether execution succeeded

gas_used

number

Gas consumed

output

string | null

Hex-encoded return data (present only on success with non-empty output)

contract_address

string | null

Deployed address (present only for successful --create transactions)

logs_count

number

Number of log entries emitted

revert_reason

string | null

Decoded revert reason (present only on revert)

halt_reason

string | null

Halt reason (present only on halt)

trace

object | null

Execution trace (when --trace is enabled without --trace.output)

state

object | null

Post-execution state dump (when --dump is enabled without --dump.output)

When --trace or --dump is used with an output file (--trace.output, --dump.output), data is written to that file and the corresponding JSON field is omitted. When no output file is specified, the data is inlined into the JSON object.

Examples

Simple bytecode execution

Execute bytecode that stores 1 in memory and returns it:

Execute from a file

Read bytecode from a hex file:

Read from stdin:

Contract deployment with --create

Deploy a contract using init code. The tool prints the deployed contract address on success:

Dump the resulting state to inspect what was deployed:

Execute with input data

Call the bytecode at the receiver address with calldata:

Pass constructor arguments in create mode (appended to init code):

Trace execution

Run with opcode-level tracing and save the output:

Full Help Output

See Also

  • Transaction Types — full option reference for --tx-type, --input, --access, and more

  • Chain and Spec — choosing a spec and chain ID

  • Block Environment — controlling block number, timestamp, coinbase, and other block fields

  • State Management — loading prestate and dumping final state

  • SALT Buckets — configuring bucket capacities for storage gas testing

  • Tracing Overview — opcode, call, and pre-state tracers

  • Cookbook — worked examples for common use cases

Last updated