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

tx

Execute a transaction against local or fork-from-RPC state.

Run a transaction with full transaction context and optional RPC state forking.

tx is similar to run but operates at the transaction level rather than the bytecode level. It handles sender nonces, transaction receipts, and — most importantly — can fork live chain state from a remote RPC endpoint so you can test against real contracts and real storage.

Usage

mega-evme tx [OPTIONS] [RAW_TX]

Raw Transaction Input

The optional RAW_TX positional argument accepts a raw EIP-2718 encoded transaction as a hex string. When you provide it, mega-evme decodes the transaction and uses it as the base for execution. Any CLI flags you pass alongside it act as field overrides on top of the decoded transaction — so you can replay a signed transaction while changing just the gas limit, input data, or any other field.

# Replay a raw signed transaction as-is
mega-evme tx 0x02f8...

# Replay the same transaction but override the input data
mega-evme tx 0x02f8... --input 0xdeadbeef

If RAW_TX is omitted, mega-evme builds the transaction entirely from CLI flags. The default sender is 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 and the default gas limit is 10000000.

Note: If the chain ID embedded in the raw transaction doesn't match --chain-id, mega-evme logs a warning but still proceeds.

Fork Mode

By default, tx runs against local state — either empty or loaded from a --prestate file. Fork mode fetches account balances, contract code, and storage slots on demand from a remote RPC node, so you can call real deployed contracts without manually constructing their state.

Flag
Default
Description

--fork

false

Enable state forking from RPC

--rpc <URL>

required

RPC endpoint to fork from (aliases: --rpc-url, --fork.rpc)

--fork.block <NUMBER>

latest

Pin the fork to a specific block number

When --fork is set, mega-evme connects to --rpc and resolves any state reads that aren't covered by a local --prestate file against that node. --fork.block pins the fork to a specific block's post-state, which is useful for reproducing historical behavior or writing deterministic tests. Without --fork.block, the fork uses the latest block at the time of execution.

--fork requires --rpc — there is no default endpoint, and the RPC_URL environment variable is not consulted:

Local --prestate overrides take precedence over forked state. This lets you patch specific accounts or storage slots while still pulling everything else from the remote node.

Options

tx accepts several shared option groups. Each group has its own reference page with the full flag table.

Group
Description
Reference

Transaction

Sender, receiver, value, gas, calldata, nonce, tx type

Transaction Types

State management

Prestate file, sender balance, faucet, storage overrides, state dump

State Management

Chain / spec

Spec version, chain ID

Chain and Spec

Block environment

Block number, timestamp, coinbase, basefee, gas limit, prevrandao

Block Environment

SALT buckets

Per-bucket capacity overrides for dynamic gas pricing

SALT Buckets

RPC cache / retry

Cache size, cache dir, retry and rate-limit

RPC Cache and Retry

Tracing

Opcode, call, and pre-state tracers with output options

Tracing Overview

Output

JSON output mode

See JSON output below

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 output includes the same fields as run --json, plus one additional field:

Field
Type
Description

receipt

object | null

Full transaction receipt with status, logs, gas usage, and contract address

Examples

Simple call to a contract

Fork from a remote RPC

Fork from a specific block

Pinning to a block number makes the execution fully deterministic regardless of when you run it.

Replay a raw transaction with an override

Decode a signed transaction from the mempool or a block, then re-run it with a different gas limit.

Fork with a patched storage slot

Fork live state but override a specific storage slot before execution — useful for testing access-controlled functions.

For more complex scenarios — multi-step state transitions, contract deployment followed by interaction, and EIP-7702 delegation flows — see the Cookbook.

Full Help Output

See Also

  • Transaction Types — full flag reference for all transaction types

  • State Management — prestate files, balance overrides, state dump

  • Chain and Spec — spec selection and chain ID

  • Block Environment — block number, timestamp, coinbase, and more

  • SALT Buckets — dynamic gas pricing configuration

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

  • Cookbook — worked examples and real-world recipes

  • run — execute raw bytecode without a full transaction context

  • replay — fetch and re-execute an on-chain transaction by hash

Last updated