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

State management

--prestate, --sender.balance, --dump, --dump.output

Chain and spec

--spec, --chain-id

Block environment

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

SALT buckets

--bucket-capacity

Tracing

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

Key defaults for run:

Option
Default

--spec

Rex4

--gas

10000000

--sender

0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

--receiver

0x0000000000000000000000000000000000000000

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

Last updated