Prerequisites
Before installing the Soroban SDK, ensure you have the following prerequisites:Install Rust
The Soroban SDK requires Rust 1.84.0 or later. Install Rust using rustup:After installation, verify your Rust version:
Make sure you have at least Rust version 1.84.0. If you have an older version, update with
rustup update.Add WASM Target
Soroban contracts compile to WebAssembly. Add the WASM target:This target is specifically designed for Soroban smart contracts.
Adding Soroban SDK to Your Project
Add SDK Dependency
Add the Soroban SDK to your
Cargo.toml:Cargo.toml
The
testutils feature is included in dev-dependencies to enable testing capabilities. It should not be used in production builds.Configure Rust Toolchain (Optional)
Create a This ensures all developers use the same Rust version and configuration.
rust-toolchain.toml file to ensure consistent builds:rust-toolchain.toml
Configure Build Profile
Add optimized build profiles to your These settings optimize for small binary size and security:
Cargo.toml:Cargo.toml
opt-level = "z": Optimize for sizeoverflow-checks = true: Runtime overflow checkingpanic = "abort": Smaller panic handlerlto = true: Link-time optimization
Building Your Contract
Once configured, build your contract with:Verification
Verify your installation by creating a simple contract:src/lib.rs
Additional Tools
Consider installing these helpful tools:Soroban CLI
Official CLI for deploying and interacting with contracts
Stellar CLI
Broader Stellar ecosystem tools
Troubleshooting
Target Not Found
If you get an error aboutwasm32v1-none not being found:
Dependency Resolution Issues
If cargo fails to resolve dependencies, try:Rust Version Conflicts
Ensure you’re using Rust 1.84.0 or later:Next Steps
Build Your First Contract
Follow our quickstart guide to create your first Soroban smart contract