Stellar

Developers

Soroban Rust SDK v30

Author

Leigh McCulloch

Publishing date

Version 30 of the Soroban Rust SDK supports Protocol 30, Bell. For contract developers it adds the two Protocol 30 features. Internally the contract build system has been improved. Most contracts that upgrade will not require code changes.

This version of the Soroban Rust SDK is not yet audited. For a list of audited versions, see the developer docs.

Announcements:

  • Build with stellar-cli v30

New features:

  • Muxed contract addresses
  • ML-DSA signature verification

Build system improvements:

  • Unique names in contract interfaces
  • Spec shaking optimisations

Build with stellar-cli v30

Contracts previously must be built with at least stellar-cli v25.2.0. In soroban-sdk v30, contracts must be built with the same major version stellar-cli, v30.0.0 or newer.

Muxed contract addresses

CAP-84 lets a contract address be muxed the same way an account address can: a contract address paired with a u64 id, contained in a strkey starting with W. A single contract address can then receive deposits that its operator attributes offchain to many customers.

Before v30 a MuxedAddress with an id was always a muxed account (M...). In v30 it may also be a muxed contract. address() returns the contract address (C...) and id() returns the id.

pub fn deposit(env: Env, to: MuxedAddress) {
    // ...
    Deposit {
        to: to.address(),     // 👈 G... or C...
        to_muxed_id: to.id(), // 👈 Option::Some for a muxed account/contract
    }
    .publish(&env);
}

A contract that reads id() must not assume the address is an account. Use address() for whoever holds the balance or authorizes.

ML-DSA signature verification

CAP-87 adds verification of ML-DSA, the post-quantum signature scheme standardized in FIPS 204. There is one function per parameter set. Like ed25519_verify, each one panics if the signature is invalid.

env.crypto().ml_dsa_44_verify(&public_key, &message, &signature, &context);
env.crypto().ml_dsa_65_verify(&public_key, &message, &signature, &context);
env.crypto().ml_dsa_87_verify(&public_key, &message, &signature, &context);

Function

Public key

Signature

ml_dsa_44_verify

1312 bytes

2420 bytes

ml_dsa_65_verify

1952 bytes

3309 bytes

ml_dsa_87_verify

2592 bytes

4627 bytes

message is the full message, not a hash. context is the FIPS 204 context string, up to 255 bytes. Pass empty Bytes if the signer used none, which is the default for most signers. Custom accounts can use these in __check_auth to accept post-quantum signatures.

Unique names in contract interfaces

Before v30 the contract interface named each type, event, and error by its Rust name alone. Two types called State in different modules or crates produced two interface entries called State, and client generators could not tell which one a function used. Tooling and clients could not interact with those contracts correctly because of the duplicate entries.

In v30 duplicate names are given unique names.

mod a {
    #[contracttype]
    pub struct State { pub count: u32 }
}

mod b {
    #[contracttype]
    pub struct State { pub enabled: bool }
}

#[contractimpl]
impl Contract {
    pub fn get(a: a::State, b: b::State) -> (a::State, b::State) {
        (a, b)
    }
}

The contract interface contains:

Rust type

Name before v30

Name in v30

a::State

State

State

b::State

State

State2

The type whose full Rust path sorts first keeps the original name. contractimport! and generated bindings handle imported interfaces the same way.

Contracts with no duplicate names will see no change. Contracts that have them will see the new type names after upgrading.

Spec shaking optimisations

This change is largely an implementation detail between the soroban-sdk and the stellar-cli's stellar contract build command. It is primarily of interest to tool builders who inspect Wasm or contract spec internals, and needs no changes to contracts.

Prior to v30 the build kept a spec entry only if a marker for it survived in the Wasm, which meant a marker for every type, event, and error was contained in the final Wasm. That is spec shaking v2, described in the "Spec shaking v2" section of the v28 post and in the v28 migration guide.

In v30 the build keeps every type and error the contract's functions refer to, directly or through other types. Markers are used only for events and for errors passed to panic_with_error!. Contracts carry fewer markers which is a small optimization.

Tools that read spec markers, the rssdk_spec_shaking meta entry, or the spec_xdr functions directly need updating. See the v30 migration guide, in particular spec markers and spec_xdr output.

Upgrading to v30

When upgrading to soroban-sdk v30:

  • Build with stellar contract build from stellar-cli v30.0.0 or newer.
  • Review contracts that read MuxedAddress::id(), as the address may now be a contract.
  • Expect generated clients to change for contracts with duplicate types, events, or errors.

This post provides an overview only. Developers should review the complete migration documentation and test their contracts and integrations before deploying with Soroban Rust SDK v30.

The full set of migration instructions, with runnable examples, are in the Rust docs:

For a full set of release notes, see the SDK's release page:

For more information about the Bell upgrade, see the Bell upgrade guide.