This guide will take you from zero to running your first interactive debug session with a Soroban smart contract.
You can install the Soroban Debugger using Cargo (Rust's package manager) or by downloading a pre-built binary.
If you have Rust installed, you can install the debugger directly from source or from crates.io:
# Install from crates.io
cargo install soroban-debuggerDownload the latest binary for your operating system from the GitHub Releases page. Extract the archive and add the soroban-debug executable to your system's PATH.
To debug a contract, you first need to compile it to WebAssembly (WASM). If you don't have a contract ready, you can use the sample provided in this repository.
-
Navigate to a contract directory:
cd examples/sample_contract -
Build the contract:
cargo build --target wasm32-unknown-unknown --release
The compiled WASM file will be located at:
target/wasm32-unknown-unknown/release/sample_contract.wasm
Now, let's run a function in the contract using the debugger. We'll use the run command, which executes a function and displays the results.
Run the expensive function with an argument of 100:
soroban-debug run \
--contract target/wasm32-unknown-unknown/release/sample_contract.wasm \
--function expensive \
--args '[100]'When you run a command, the debugger provides a detailed summary:
- Result: The value returned by the function (e.g.,
Ok(1234567)). - Budget: How much CPU and Memory the execution consumed.
- Storage: Any changes made to the contract's persistent storage.
- Events: Any events emitted during execution.
If you want to step through the code instruction by instruction, use the interactive mode:
soroban-debug interactive --contract target/wasm32-unknown-unknown/release/sample_contract.wasmInside the interactive shell, you can use commands like:
s(step): Execute the next instruction.i(inspect): View the current stack and local variables.storage: View the current contract storage.q(quit): Exit the debugger.
- Explore Source-Level Debugging to map WASM back to your Rust code.
- Learn about Time-Travel Debugging to step backward through execution.
- Check the FAQ for troubleshooting common issues.
For release readiness gates (CLI + extension + analyzer + benchmarks), follow:
docs/release-checklist.md