soroban-sdk 27.0.0

Soroban SDK.
Documentation

Soroban SDK supports writing smart contracts for the Wasm-powered Soroban smart contract runtime, deployed on Stellar.

Docs

See developers.stellar.org for documentation about building smart contracts for Stellar.

Support

The two most recent soroban-sdk major releases are supported with critical security fixes. Critical security issues may be backported to earlier versions if practical, but not guaranteed. General bugs are only fixed on, and new features are only added to, the latest major release.

Build Target

Contracts must be built for the wasm32v1-none target, available with Rust 1.84+. It is the only wasm target supported by the Soroban runtime on Stellar.

Build contracts with stellar contract build from stellar-cli, which targets wasm32v1-none and applies the build settings the Soroban runtime requires. Do not build contracts with cargo build.

The wasm32-unknown-unknown target is not supported when building with Rust 1.82 or newer, because on those versions the target enables wasm features (reference-types, multi-value) that the Soroban environment does not support and that cannot be easily disabled. Building for wasm32-unknown-unknown on Rust 1.82+ produces a build error.

Features

See [_features] for a list of all Cargo features and what they do.

Migrating Major Versions

See [_migrating] for a summary of how to migrate from one major version to another.

Examples

use soroban_sdk::{contract, contractimpl, vec, symbol_short, BytesN, Env, Symbol, Vec};

#[contract]
pub struct Contract;

#[contractimpl]
impl Contract {
    pub fn hello(env: Env, to: Symbol) -> Vec<Symbol> {
        vec![&env, symbol_short!("Hello"), to]
    }
}

#[test]
fn test() {
# }
# #[cfg(feature = "testutils")]
# fn main() {
    let env = Env::default();
    let contract_id = env.register(Contract, ());
    let client = ContractClient::new(&env, &contract_id);

    let words = client.hello(&symbol_short!("Dev"));

    assert_eq!(words, vec![&env, symbol_short!("Hello"), symbol_short!("Dev"),]);
}
# #[cfg(not(feature = "testutils"))]
# fn main() { }

More examples are available at: