A command-line debugger for Soroban smart contracts on the Stellar network. Debug your contracts interactively with breakpoints, step-through execution, state inspection, and budget tracking.
- Quick Start
- User Journeys
- Command Index
- Reference
- Interactive Commands
- Examples
- Troubleshooting
- Contributing
- License
cargo install soroban-debuggergit clone https://github.com/Timi16/soroban-debugger.git
cd soroban-debugger
cargo install --path .Debug a contract by specifying the WASM file and function to execute:
soroban-debug run --contract token.wasm --function transfer --args '["Alice", "Bob", 100]'For an interactive session with a terminal UI:
soroban-debug interactive --contract my_contract.wasm --function helloFor a comprehensive introduction, see the Getting Started Guide.
Learn how to execute functions, pass complex arguments, and use the interactive debugger.
- Basic Execution: Use the
runcommand to execute functions and see results immediately. - Interactive Mode: Use
interactivefor a step-by-step walkthrough with breakpoints. - REPL: Use
replfor repeated calls and exploration without restarting. - Complex Arguments: Support for JSON-nested vectors, maps, and typed annotations.
Debug your Rust code directly instead of raw WASM instructions.
- Rust Source Mapping: Automatically maps WASM offsets back to Rust lines using DWARF debug info.
- Instruction Stepping: Step into, over, or out of functions at the source level.
- Source Map Caching: Fast O(1) lookups for source locations after the first load.
See Source-Level Debugging Guide for details.
Debug contracts running on remote servers or in CI environments.
- Debug Server: Start a
serverprocess to host a debugging session. - Remote Client: Connect to a running server using the
remotecommand. - Secure Connections: Support for TLS and token-based authentication.
See Remote Debugging Guide for setup instructions.
Analyze contract metadata, resource usage, and upgrade compatibility.
- Inspection: Use
inspectto view contract functions and metadata without executing. - Profiling: Use
profileto find hotspots and budget-heavy execution paths. - Optimization: Use
optimizefor automated gas and performance suggestions. - Upgrade Checks: Use
upgrade-checkto ensure API compatibility between versions.
Integrate debugging into your CI/CD pipeline and discover edge cases.
- Scenarios: Define multi-step integration tests in simple TOML files.
- Batch Execution: Run the same function with multiple argument sets in parallel.
- Symbolic Analysis: Automatically explore input spaces to find panics and edge cases.
- Test Generation: Generate ready-to-run Rust unit tests from any debug session.
| Category | Commands |
|---|---|
| Run & Debug | run, interactive, repl, tui, scenario, replay |
| Analyze & Compare | inspect, upgrade-check, optimize, profile, compare, symbolic, analyze |
| Remote & Server | server, remote |
| Utilities | completions, history-prune |
Use
soroban-debug <command> --helpfor full flags and examples.
The debugger supports passing typed arguments via the --args flag.
| JSON Value | Soroban Type | Example |
|---|---|---|
| Number | i128 |
10, -5 |
| String | Symbol |
"hello" |
| Boolean | Bool |
true |
| Array | Vec<Val> |
[1, 2, 3] |
| Object | Map |
{"key": "value"} |
For precise control, use {"type": "...", "value": ...}:
u32, i32, u64, i64, u128, i128, bool, symbol, string, address.
Filter large storage outputs by key pattern using --storage-filter:
# Prefix match: keys starting with "balance:"
soroban-debug run --contract token.wasm --function mint \
--storage-filter 'balance:*'
# Regex match: keys matching a pattern
soroban-debug run --contract token.wasm --function mint \
--storage-filter 're:^user_\d+$'
# Exact match
soroban-debug run --contract token.wasm --function mint \
--storage-filter 'total_supply'
# Multiple filters (combined with OR)
soroban-debug run --contract token.wasm --function mint \
--storage-filter 'balance:*' \
--storage-filter 'total_supply'You can export a full record of the contract execution to a JSON file using the --trace-output flag. This trace captures function calls, arguments, return values, storage snapshots (before and after), events, and budget consumption.
soroban-debug run \
--contract contract.wasm \
--function hello \
--trace-output execution_trace.jsonThese traces can later be used with the compare command to identify regressions or differences between runs.
An exported trace includes versioning, metadata, and full execution state:
{
"version": "1.0",
"label": "Execution of hello",
"contract": "CA7QYNF5GE5XEC4HALXWFVQQ5TQWQ5LF7WMXMEQG7BWHBQV26YCWL5",
"function": "hello",
"args": "[\"world\"]",
"storage_before": {
"counter": "0"
},
"storage": {
"counter": "1"
},
"budget": {
"cpu_instructions": 1540,
"memory_bytes": 450,
"cpu_limit": 1000000,
"memory_limit": 1000000
},
"return_value": "void",
"call_sequence": [
{
"function": "hello",
"args": "[\"world\"]",
"depth": 0,
"budget": {
"cpu_instructions": 1540,
"memory_bytes": 450
}
}
],
"events": [
{
"contract_id": "CA7Q...",
"topics": ["\"greeting\""],
"data": "\"Hello, world!\""
}
]
}| Pattern | Type | Matches |
|---|---|---|
balance:* |
Prefix | Keys starting with balance: |
re:^user_\d+$ |
Regex | Keys matching the regex |
total_supply |
Exact | Only the key total_supply |
Start an interactive debugging session:
soroban-debug interactive [OPTIONS]
Options:
-c, --contract <FILE> Path to the contract WASM fileView contract information without executing:
soroban-debug inspect [OPTIONS]
Options:
-c, --contract <FILE> Path to the contract WASM file
--source-map-diagnostics
Print resolved mappings, missing DWARF sections, and fallback behavior
--dependency-graph Export cross-contract dependency graph (DOT + Mermaid)Use soroban-debug inspect --contract my_contract.wasm --source-map-diagnostics --format json
when you want a non-interactive DWARF triage report for CI or editor tooling.
For full examples, see docs/dependency-graph.md.
Compare two contract binaries for API breakage and execution differences before releasing:
soroban-debug upgrade-check --old current.wasm --new upgraded.wasmThe debugger runs parallel traces and classifies the upgrade:
- Safe: No breaking changes, stable inputs execution.
- Caution: Non-breaking changes like new map arguments or endpoints.
- Breaking: Removed functions, changed signatures, or execution panic regressions.
Generate shell completion scripts for your favorite shell:
soroban-debug completions bash > /usr/local/etc/bash_completion.d/soroban-debugSupported shells: bash, zsh, fish, powershell.
Bash:
soroban-debug completions bash > /usr/local/etc/bash_completion.d/soroban-debugZsh:
soroban-debug completions zsh > /usr/local/share/zsh/site-functions/_soroban-debugFish:
soroban-debug completions fish > ~/.config/fish/completions/soroban-debug.fishPowerShell:
soroban-debug completions powershell >> $PROFILECompare two execution trace JSON files side-by-side to identify differences and regressions in storage, budget, return values, and execution flow:
soroban-debug compare <TRACE_A> <TRACE_B> [OPTIONS]
Options:
-o, --output <FILE> Output file for the comparison report (default: stdout)Example:
# Compare two saved execution traces
soroban-debug compare examples/trace_a.json examples/trace_b.json
# Save report to a file
soroban-debug compare baseline.json new.json --output diff_report.txtSee doc/compare.md for the full trace JSON format reference
and a regression testing workflow guide.
soroban-debug run \
--contract token.wasm \
--function transfer \
--args '["user1", "user2", 100]'Pass JSON objects as Map arguments:
# Flat map argument
soroban-debug run \
--contract token.wasm \
--function update_user \
--args '{"user":"ABC","balance":1000}'
# Nested map argument
soroban-debug run \
--contract token.wasm \
--function update_user \
--args '{"user":"ABC","balance":1000,"metadata":{"verified":true,"level":"premium"}}'
# Mixed-type values in map
soroban-debug run \
--contract dao.wasm \
--function create_proposal \
--args '{"title":"Proposal 1","votes":42,"active":true,"tags":["important","urgent"]}'Output:
> Debugger started
> Paused at: transfer
> Args: from=user1, to=user2, amount=100
(debug) s
> Executing: get_balance(user1)
> Storage: balances[user1] = 500
(debug) s
> Executing: set_balance(user1, 400)
(debug) storage
Storage:
balances[user1] = 400
balances[user2] = 100
(debug) c
> Execution completed
> Result: Ok(())
soroban-debug run \
--contract dao.wasm \
--function execute \
--breakpoint verify_signature \
--breakpoint update_statesoroban-debug run --contract token.wasm --function mint --storage-filter 'balance:*'Supports prefix*, re:<regex>, and exact_match.
Load default settings from .soroban-debug.toml:
[debug]
breakpoints = ["verify", "auth"]
[output]
show_events = true| Symptom | Likely Cause | Solution |
|---|---|---|
| Request timed out | Slow host or low timeout | Increase --timeout-ms |
| Incompatible protocol | Build version mismatch | Reinstall client/server from same release |
| Auth failed | Token mismatch | Verify --token values match |
For more scenarios, see the Full FAQ and Remote Troubleshooting Guide.
Please see CONTRIBUTING.md for setup and workflow.
Licensed under Apache 2.0 or MIT.