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, withcompile_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 DuckPoolsInterestRateskipped 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 from the log:
- The work moved the
ergoscript-compilercrate beyond arithmetic-only examples toward broader ErgoScript language coverage. - A later pass started adding remaining
SigmaPredef.scalafunctions andmethods.scalamethods 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.
Compatibility notes:
- Some historical mainnet trees use pre-v3 or pre-JIT behavior. The log records fixes for 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.
Crates#
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
ErgoTree IR and serialization.
ErgoScript compiler.
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.
- Wasm:
- Crate:
ergo-lib-wasm
- Crate:
- JavaScript / TypeScript:
- Browser:
ergo-lib-wasm-browser - Node.js:
ergo-lib-wasm-nodejs
- Browser:
- Swift (iOS):
- Repo:
ergo-lib-ios
- Repo:
- Java / JVM:
- Repo:
ergo-lib-jni
- Repo:
- C:
- Repo:
ergo-lib-c
- Repo:
- Go:
- Repo:
ergo-lib-go(Note: Community maintained)
- Repo:
- Ruby:
- Repo:
sigma_rb(Note: Community maintained)
- Repo:
- Python:
- Package:
ergo-lib-python(Note: Uses ergo-lib crate docs)
- See also: ergo-lib-python docs
- Package:
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:
- Oracle Core;
- Ergo Headless dApp Framework;
- Ergo Node Interface Library;
- Spectrum Off-Chain Services for Ergo;
- AgeUSD Stablecoin Protocol;
- ErgoNames SDKs
TS/JS:
- Ergo SDK (Wasm bindings);
- Yoroi wallet (Wasm bindings);
- Ergo Desktop Wallet (Wasm bindings);
Examples:
Also take a look at tests where various usage scenarios were implemented.