Skip to content

Sigma Rust#

Overview#

Rust implementation of ErgoScript (sigmastate-interpreter) cryptocurrency scripting language.

Recent updates#

  • Apr 20: the ErgoScript Rust compiler in sigma-rust PR #862 reached byte-identical output for 12 of 15 production contracts, with compile_canonical() added as a safety fallback that verifies against a Scala node and uses node bytes if local output differs.
  • Apr 22: 15 of 15 production contracts and 20+ contracts tested byte-identical, with 185 tests green.
  • Apr 23: 31 test contracts matched the Scala node with 196 tests and no canonical fallbacks. Contracts tested included SigmaUSD, Rosen GuardSign, Spectrum DEX, DuckPools, Dexy, Oracle Pool v2, Off-the-grid, Crystal Pool, Phoenix HodlERG, governance, lending, AMM swaps, multisig, vesting, and BigInt arithmetic patterns.
  • Apr 26: coverage reached 45 of 46 tested contracts, with 203 tests and only DuckPools InterestRate skipped because its deeply nested BigInt polynomial overflowed recursive CSE.
  • Several consensus and compatibility PRs were opened while the Rust node was syncing mainnet, including fixes for context extension ordering, NiPoPoW proof serving, JIT costing parity, lazy constant resolution, and pre-JIT compatibility paths.

The compiler work keeps two modes: compile() is pure Rust and dependency-free, while compile_canonical() keeps the Scala-node fallback for untested contract patterns where byte mismatch would create a different P2S address.

Additional compiler details:

  • The work moved the ergoscript-compiler crate beyond arithmetic-only examples toward broader ErgoScript language coverage.
  • A later pass started adding remaining SigmaPredef.scala functions and methods.scala methods after testing key ecosystem dApp contracts exposed missing coverage.
  • Byte-identical output matters because a byte mismatch produces a different P2S address, which can make funds unreachable if a contract was compiled by the wrong implementation.
  • WASM/browser targets were mentioned as a roadmap item, not a completed feature.
  • Community editor tooling includes ergoscript-compiler-lsp and a matching Zed extension. Treat these as experimental until their repositories document stable releases.

Compatibility notes:

  • Some historical mainnet trees use pre-v3 or pre-JIT behavior. Compatibility work covers cases where the JVM interpreter is more permissive than sigma-rust.
  • The Rust node sync process was used as a differential test source for sigma-rust by comparing behavior against the Scala reference implementation.
  • Tooling using sigma-rust should still treat the Scala node as consensus authority unless a release explicitly states parity for the relevant path.

Library and binding notes:

  • bounded-vec is an Ergo Platform Rust utility crate for vectors with type-level lower and upper bound guarantees. It is low-level infrastructure rather than an application SDK, but useful context when following Rust dependency work around Sigma libraries.
  • UnsignedBigInt support has been added to C/Swift bindings.
  • Python bindings track newer pyo3 for Python 3.14 support.
  • WASM serializes SigmaBoolean values as base-16 strings.
  • ergo-lib and WASM bindings have moved through newer Rust toolchains and dependency updates; downstream projects should pin compatible package versions rather than assuming every binding release supports the same host toolchain.

Crates#

ergo-lib Latest Version Documentation

Overarching crate exposing wallet-related features: chain types (transactions, boxes, etc.), JSON serialization, box selection for tx inputs, tx builder and signing. Exports other crates API, probably the only crate you'd need to import.

ergotree-interpreter Latest Version Documentation

ErgoTree interpreter

ergotree-ir Latest Version Documentation

ErgoTree IR and serialization.

ergoscript-compiler Latest Version Documentation

ErgoScript compiler.

sigma-ser Latest Version Documentation

Ergo binary serialization primitives.

Bindings#

This section lists available language bindings for sigma-rust, allowing developers to interact with the Ergo blockchain using various programming languages.

Usage Examples#

To get better understanding on how to use it in your project check out how its being used in the following projects:

Rust:

TS/JS:

Examples:

Also take a look at tests where various usage scenarios were implemented.