Skip to main content
The Rust SDK is the application API for building Stoffel into your product. Its Cargo package is stoffel-rust-sdk; the Rust crate you import is stoffel.
Stoffel 0.1.0 Rust SDKInstall the CLI for project commands. Add the Rust SDK when your app needs to compile, load, or run Stoffel programs directly.

Prerequisites

  • Rust and Cargo, latest stable recommended
  • The stoffel CLI
  • stoffel-rust-sdk from crates.io
  • A local checkout of Stoffel-Labs/stoffel only when you need source examples or local crate changes
Install the CLI:

Add the SDK from crates.io

Optional: use a local checkout

Use a path dependency when your app needs local SDK source changes:
Adjust the relative path to match your project layout.

Verify clear execution

Create src/main.rs:
Run it:
Expected output:

Verify local MPC execution

For an app-shaped local MPC check, build your Stoffel project first and load the bytecode from Rust:
.execute_local().await? runs local MPC testing by spawning several MPC nodes/processes on your machine.

Current SDK surface

The SDK currently includes:
  • Stoffel::compile(source) and Stoffel::compile_file(path) for source compilation.
  • Stoffel::load(bytecode) and Stoffel::load_file(path) for bytecode loading.
  • with_inputs(&[(name, value)]) for named function inputs.
  • with_client_input(slot, &[values]) for ClientStore-style local MPC programs.
  • execute_clear() for fast local logic checks.
  • execute_local().await and execute_local_function(name).await for local MPC execution.
  • parties(n) and threshold(t) MPC configuration.
  • bytecode save/load and summary helpers.
  • network deployment/config builders for multi-node experiments.
  • observability and error-category helpers.
  • on-chain coordinator handles for integration experiments.

Examples in the repository

The SDK examples live at:
Useful starting points:
ExampleWhat it shows
quickstart.rsClear local execution with named inputs.
local_mpc_named_inputs.rsRecommended local MPC smoke test using Share values with named inputs.
local_mpc_client_input.rsRecommended ClientStore smoke test using local client slots.
quickstart_mpc.rsDirect secret int64 argument example; useful for reading, but the Share and ClientStore examples are the more reliable current smoke tests.
bytecode_roundtrip.rsSave bytecode, load it back, and execute.
network_config.rsGenerate and parse network deployment TOML.
observability.rsTracing, metrics, server health, and error categories.
onchain.rsOn-chain coordinator handle setup.
Run an example from the repository:

Troubleshooting

use stoffel::prelude::* cannot resolve

Confirm that your dependency renames the crates.io package to the library crate name:

Cargo builds take a while

The SDK pulls MPC, networking, and coordinator crates through Cargo. The first build can take several minutes.

Next steps