simulate-upgrade command replays a transaction with new contract code to verify if a planned upgrade will break existing functionality.
Usage
Description
This command:- Fetches an existing transaction from the network
- Replaces the contract code with your new WASM file
- Re-simulates the transaction execution
- Reports any behavioral changes or failures
Examples
Flags
string
required
Path to the new WASM file to test
boolean
default:"false"
Run dead-code elimination on the WASM before simulation
string
default:"mainnet"
Network to fetch transaction from:
testnet, mainnet, or futurenetstring
Custom Soroban RPC URL (overrides default for network)
Workflow
1
Fetch original transaction
Downloads the transaction envelope and ledger state from the network
2
Load new WASM
Reads and optionally optimizes your new contract code
3
Replace contract code
Substitutes the old contract WASM with your new version
4
Simulate execution
Re-runs the transaction with the new code
5
Compare results
Shows differences in events, budget usage, and outcomes
Understanding the output
The simulation output shows:Common use cases
Testing bug fixes
Testing bug fixes
Verify that your bug fix resolves the issue without changing behavior for other transactions:
Performance improvements
Performance improvements
Measure the performance impact of optimizations:
Breaking change detection
Breaking change detection
Ensure API changes don’t break existing callers:
Best practices
Test multiple transactions: Don’t rely on a single transaction. Test your upgrade against a variety of real transactions to catch edge cases.
Use optimization: Always test with
--optimize to ensure the deployed WASM will behave the same as your simulation.