Skip to main content
Simultaneously replay a transaction against a local WASM file and the on-chain contract, then display a side-by-side diff.

Usage

Description

The compare command is the primary tool for β€œWhat broke when I updated my contract?” debugging. It works by:
  1. Fetching the transaction envelope and ledger state from the network
  2. Running two simulation passes in parallel:
    • Pass A: Uses your local WASM file (--wasm)
    • Pass B: Uses the on-chain WASM (normal replay)
  3. Displaying a color-coded side-by-side diff of the results
This command is essential for testing contract changes before deployment and understanding behavioral differences.

Examples

Arguments

string
required
Stellar transaction hash to replay and compare

Flags

Required

string
required
Path to local WASM file for comparisonThis is the contract version you want to test against the on-chain version.

Network configuration

string
default:"mainnet"
Stellar network to useOptions: testnet, mainnet, futurenetAlias: -n
string
Custom Soroban RPC URLCan specify multiple URLs separated by commas for fallback.
string
RPC authentication tokenCan also use ERST_RPC_TOKEN environment variable.

Optimization

boolean
default:"false"
Run dead-code elimination on local WASM before simulationUseful for comparing optimized vs unoptimized builds.
string[]
Mock arguments to pass to the local WASM executionCan be specified multiple times: --args arg1 --args arg2

Output options

boolean
default:"false"
Print full simulation JSON for both passesAlias: -v
string
Color theme for diff outputOptions: default, deuteranopia, protanopia, tritanopia, high-contrast

Advanced options

uint32
Override protocol version for both simulation passesExamples: 20, 21, 22
string
Path to erst-sim binaryOverrides auto-discovery.

Output

The compare command displays:
If --optimize is used, shows optimization report:

Side-by-side diff

Displays differences in:
  • Events: Contract events emitted during execution
  • Diagnostic output: Debug logs and traces
  • Budget usage: CPU instructions, memory bytes, operations
  • Call paths: Function call trees showing divergence points
  • Return values: Different results or error codes

Use cases

Pre-deployment testing

Test contract changes before deploying:

Debugging behavior changes

Understand why a transaction behaves differently:

Optimization validation

Verify optimizations don’t change behavior:

Protocol upgrade testing

Test contract behavior on new protocol versions:

Parallel execution

Both simulation passes run in parallel for performance:
  • Faster total execution time
  • Identical ledger state for both passes
  • Consistent timestamp and protocol version
The parallel execution ensures a fair comparison by using exactly the same network conditions for both passes.

Verbose mode

With --verbose, shows full JSON output for each pass:

Error handling

Common errors and solutions:

WASM file not found

Solution: Check the path and ensure the file exists:

Invalid transaction hash

Solution: Provide a valid 64-character hex hash:

Simulation failed

Solution: Ensure WASM is valid and compatible:
  • debug - Debug individual transactions
  • trace - Explore execution traces interactively
  • profile - Analyze gas consumption differences