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
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)
--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.
Transaction
--create, --gas, --basefee, --priority-fee, --tx-type, --value, --sender, --receiver, --nonce, --input, --inputfile, --source-hash, --mint, --auth, --access
Block environment
--block.number, --block.coinbase, --block.timestamp, --block.gaslimit, --block.basefee, --block.difficulty, --block.prevrandao, --block.blobexcessgas
Key defaults for run:
--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
--createDeploy 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 moreChain 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