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 0xdeadbeefIf 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-evmelogs 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.
--fork
false
Enable state forking from RPC
--fork.rpc <URL>
http://localhost:8545
RPC endpoint to fork from (env: RPC_URL)
--fork.block <NUMBER>
latest
Pin the fork to a specific block number
When --fork is set, mega-evme connects to --fork.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.
You can set the RPC URL via the RPC_URL environment variable instead of passing --fork.rpc every time:
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.
State management
Prestate file, sender balance, faucet, storage overrides, state dump
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 contextreplay— fetch and re-execute an on-chain transaction by hash
Last updated