Skip to main content
The Stoffel repository includes runnable StoffelLang programs under crates/stoffel-lang/examples/. Use them to learn the language, read client-provided private inputs, compose MPC primitives, and adapt private workflows into your own app. If you are new to StoffelLang, start with these examples in order:
  1. local_control_flow — learn functions, loops, ranges, branching, and arithmetic.
  2. local_collections — work with lists, indexing, appending, and length checks.
  3. mpc_client_private_score — read a client-provided private input and return an output share.
  4. mpc_secure_comparison — study a reusable MPC primitive that reveals only a comparison bit.
  5. mpc_histogram or mpc_first_price_auction — see how primitives become app-shaped private workflows.
This path starts with clear StoffelLang syntax, then moves into private inputs, explicit reveal boundaries, and larger MPC application patterns.

Run the examples

Clone the Stoffel repository and validate the examples from the repository root:
The validation script compiles the examples, runs local-only examples through the VM, and writes compiled bytecode to examples/dist/. A failure usually means the local CLI/compiler checkout is out of sync or the example needs a specific input shape from its README.

Run a clear language example

Start with a clear example when you want the lowest-friction check:

Run a client-input MPC example

Read each example README before running MPC examples, because client slots and input values are example-specific. For mpc_client_private_score:

Choose by job

Reuse MPC building blocks

These examples are useful when you need source-level patterns for a private computation boundary: When adapting these examples, copy the computation pattern, not the whole directory structure. Keep private inputs at ClientStore, keep intermediate values secret, and make reveal or client-output points explicit.

Study larger workflows

Use these after you understand the smaller building blocks: Ordinary app logic should stay in the host application. The StoffelLang program should contain the private computation, the client input reads, and the explicit reveal or client-output boundary. Use the Rust SDK examples when you are ready to embed a StoffelLang program in application code.

Coverage matrix

For complete language and builtin coverage, read crates/stoffel-lang/examples/COVERAGE.md. The matrix maps syntax, runtime semantics, ClientStore APIs, Share APIs, MPC metadata, crypto builtins, AVSS helpers, and RBC helpers to specific examples.

See also