Skip to main content
The 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
This allows you to test contract upgrades before deploying them to the network.

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 futurenet
string
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:
If the simulation fails or produces different events, review the changes carefully before deploying the upgrade.

Common use cases

Verify that your bug fix resolves the issue without changing behavior for other transactions:
Measure the performance impact of optimizations:
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.
Automate testing: Integrate simulate-upgrade into your CI/CD pipeline to catch breaking changes before deployment.
  • compare - Compare local vs on-chain execution side-by-side
  • init - Initialize Erst workspace for testing
  • doctor - Verify environment setup