thruput-sdk 0.58.0

Thruput smart-contract SDK for Rust (rv32 guest runtime and native test harness)
Documentation

Thruput Rust SDK

Write smart contracts in Rust for Thruput's RV32 runtime. The SDK provides contract macros, generated clients, persistent storage types, typed exceptions, events, and a native test environment.

Start a contract

Use the thruput CLI to create and build a contract:

thruput new my-contract
cd my-contract
thruput build

See Getting Started for installing the CLI and setting up a network. The scaffold supplies the manifest, contract library, RV32 binary wrapper, and pinned Rust toolchain. Keep its entrypoints feature and src/main.rs wrapper: they link the contract's entrypoints into the deployed artifact.

To work without the CLI, follow the Cargo-only guide. It covers a standalone manifest, native tests, and an RV32 ELF build.

Test a contract natively

Native tests run contracts in-process against the Thruput executor, with no guest build. Enable them with the SDK's dev feature, and call thruput_sdk::declare_mock_contract!() in the contract library to generate register_mock_contract.

For a single transaction, thruput_sdk::client_test deploys a registered contract and passes its generated client to a closure:

#[test]
fn increment_counter() {
    thruput_sdk::client_test(
        |env| counter::register_mock_contract(env),
        |client: &counter::CounterClient| {
            client.initialize(10);
            client.increment(5);
            assert_eq!(client.get(), 15);
        },
    );
}

Use TestEnvironment::transact for multiple transactions, multiple contracts, or frame-level exception and fault assertions. The counter tests show deployment and error inspection, and the multi-transaction tests show persistent state across transactions.

Features

Feature Use
alloc Heap allocation in guest builds
std Required for host builds; forbidden on the guest
dev The native test environment
remote Off-chain proxies for calling deployed contracts
logging Traces contract calls in native tests

Arithmetic

Contract release builds disable overflow checks. Integer operators, including U256 and I256, can wrap on-chain where a native test panics. Use checked arithmetic for amounts: a passing native test does not establish guest overflow behavior. The SDK guide covers checked operations, full-precision multiplication and division, and storage guards.

Documentation

  • The SDK guide explains the generated code, features, storage, calls, and errors. It is also the crate-level rustdoc.
  • thruput-examples has worked contracts.
  • example-contracts/ in this repository is the SDK's test corpus. Its fixtures exercise SDK behavior and are not audited application templates.

Contributing

See CONTRIBUTING.md for setting up this repository, building guest contracts, and running CI.

License

Copyright 2026 Stellar Development Foundation. Licensed under the Apache License, Version 2.0. Each published crate includes the workspace LICENSE.