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
Stellar transaction hash to replay and compare
Flags
Required
Path to local WASM file for comparisonThis is the contract version you want to test against the on-chain version.
Network configuration
Stellar network to useOptions:
testnet, mainnet, futurenetAlias: -nCustom Soroban RPC URLCan specify multiple URLs separated by commas for fallback.
RPC authentication tokenCan also use
ERST_RPC_TOKEN environment variable.Optimization
Run dead-code elimination on local WASM before simulationUseful for comparing optimized vs unoptimized builds.
Mock arguments to pass to the local WASM executionCan be specified multiple times:
--args arg1 --args arg2Output options
Print full simulation JSON for both passesAlias:
-vColor theme for diff outputOptions:
default, deuteranopia, protanopia, tritanopia, high-contrastAdvanced options
Override protocol version for both simulation passesExamples: 20, 21, 22
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: