Usage
Description
Thecompare command is the primary tool for βWhat broke when I updated my contract?β debugging. It works by:
- Fetching the transaction envelope and ledger state from the network
- Running two simulation passes in parallel:
- Pass A: Uses your local WASM file (
--wasm) - Pass B: Uses the on-chain WASM (normal replay)
- Pass A: Uses your local WASM file (
- 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: -nstring
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 arg2Output options
boolean
default:"false"
Print full simulation JSON for both passesAlias:
-vstring
Color theme for diff outputOptions:
default, deuteranopia, protanopia, tritanopia, high-contrastAdvanced 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:Header
--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
- Events diff
- Budget diff
- Error diff
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: