| Crates.io | simfony |
| lib.rs | simfony |
| version | 0.1.0 |
| created_at | 2025-04-14 20:44:06.257809+00 |
| updated_at | 2025-04-14 20:44:06.257809+00 |
| description | Rust-like language that compiles to Simplicity bytecode. |
| homepage | https://github.com/BlockstreamResearch/simfony/ |
| repository | https://github.com/BlockstreamResearch/simfony/ |
| max_upload_size | |
| id | 1633365 |
| size | 528,605 |
Simfony is a high-level language for writing Bitcoin smart contracts.
Simfony looks and feels like Rust. Just how Rust compiles down to assembly language, Simfony compiles down to Simplicity bytecode. Developers write Simfony, full nodes execute Simplicity.
Simfony is a work in progress and is not yet ready for production use.
let a: u32 = 10;
let b = {
let c: u32 = 2;
let d: u32 = 3;
assert!(jet::eq_32(a, 10)); // Use variables from outer scopes
let a: u32 = 7; // Shadow variables from outer scopes
jet::max_32(jet::max_32(c, d), a) // Missing ; because the block returns a value
};
assert!(jet::eq_32(b, 7));
Take a look at the example programs.
This crate should compile with any feature combination on Rust 1.78.0 or higher.
Simplicity introduces a groundbreaking low-level programming language and machine model meticulously crafted for blockchain-based smart contracts. The primary goal is to provide a streamlined and comprehensible foundation that facilitates static analysis and encourages reasoning through formal methods. While the elegance of the language itself is distilled into something as succinct as fitting onto a T-shirt, it's important to note that the simplicity of the language doesn't directly equate to simplicity in the development process. Simfony revolves around demystifying and simplifying the complexities involved in this ecosystem.
The distinguishing aspects that set Simplicity apart from conventional programming languages are:
Simfony is a high-level language that compiles to Simplicity. It maps programming concepts from Simplicity onto programming concepts that developers are more familar with. In particular, Rust is a popular language whose functional aspects fit Simplicity well. Simfony aims to closely resemble Rust.
Just how Rust is compiled to assembly language, Simfony is compiled to Simplicity. Just how writing Rust doesn't necessarily produce the most efficient assembly, writing Simfony doesn't necessarily produce the most efficient Simplicity code. The compilers try to optimize the target code they produce, but manually written target code can be more efficient. On the other hand, a compiled language is much easier to read, write and reason about. Assembly is meant to be consumed by machines while Rust is meant to be consumed by humans. Simplicity is meant to be consumed by Bitcoin full nodes while Simfony is meant to be consumed by Bitcoin developers.
Clone the repo and build the Simfony compiler using cargo.
git clone https://github.com/BlockstreamResearch/simfony.git
cd simfony
cargo build
Optionally, install the Simfony compiler using cargo.
cargo install --path .
The Simfony compiler takes two arguments:
.simf).wit, optional)The compiler produces a base64-encoded Simplicity program. Witness data will be included if a witness file is provided.
./target/debug/simc examples/test.simf examples/test.wit
See the installation instructions.