Designing Bitcoin Smart Contracts with Sapio (available on Mainnet today)



Summary:

Jeremy Rubin introduces Sapio, a shallow e-DSL built in Rust for Bitcoin smart contract programming flows. He cites his experience with BlueSpec and the target of program compilation being transaction circuits as inspiration for Sapio. Sapio is designed to be Turing complete for federated operators, allowing for tracking logic via updatable finish clauses while only producing a finite deterministic "binary" of transactions. It has plans to integrate Miniscript as the backend key description language and is similar to Solidity, except that Solidity contracts are "stateless". The hosting language is full, general, and Turing-complete, building up a total (non-Turing-complete) contract description. ZmnSCPxj speculates that it would be possible to design a language with two layers, a non-Turing-complete total "base language" and a syntax meta-language similar to Scheme `syntax-rules`, which constructs ASTs for the "base language". The advantage of this scheme is that the meta-language is executed at language compile time, and the developer can see whether the meta-program halts or not. Jeremy argues embedded DSL for hardware description languages have been pushed in the past but became unpopular for requiring users to learn both the hosting language and the embedded language. Further, an utterance in an embedded DSL is expected to be longer than an utterance in a non-embedded DSL. With embedded Rust, one can transfer all existing knowledge on Rust programming and add a veneer of Sapio. Sapio targets WASM happily, which helps with compile-once run sandboxed anywhere. It is designed to not just compile to smart contracts as Bitcoin addresses but also be able to be deeply integrated inside an application.


Updated on: 2023-06-14T20:02:00.048698+00:00