Subject: [bitcoin-dev] Designing Bitcoin Smart Contracts with Sapio (available on Mainnet today)

From: Jeremy <[email-masked]>
Date: Thu, 8 Apr 2021 20:57:39 -0700

Bitcoin Developers,

I'm very excited to introduce Sapio[0] <https://github.com/sapio-lang/sapio>
formally to you all.

Sapio empowers Bitcoin Developers to craft smart contracts in an intuitive,
safe, and composable way. Sapio challenges the notion that you can't make
complex smart contracts for Bitcoin, and opens the floodgates for a myriad
of new ideas to be defined easily. Sapio works today on mainnet without any
protocol changes (via user-configurable multisig oracles, it will work
with BIP-119
OP_CHECKTEMPLATEVERIFY[1] <https://utxos.org> and Taproot when they are
available).

You can learn more about what's possible by reading *Designing Bitcoin
Smart Contracts with Sapio[2] <https://learn.sapio-lang.org>*. My Reckless
VR Talk[3] <https://judica.org/blog/sapio/> also does a great job of
breaking down the core programming model for Sapio contracts, although the
language has evolved substantially since I gave the talk.

As a concrete instance of Sapio working in the wild, I am currently
executing on mainnet a Congestion Control Tree[4]
<https://utxos.org/analysis/bip_simulation/> contract with 25 recipients
(the first Sapio contract to run on mainnet ever, as far as I'm aware). You
can review the source code, arguments, compiler outputs, and transactions
here[5]
<https://gist.github.com/JeremyRubin/1374f0916bfdef0bd36bc10d73852886>.

To see more examples of what you can do with Sapio, the repo includes
examples[6]
<https://github.com/sapio-lang/sapio/tree/master/sapio-contrib/src/contracts>
for derivatives, vaults, coin pools, games, side chains, and more. These
aren't intended to be production grade contracts -- yet -- but are
demonstrative of what can be built and how. I'm excited to see what people
build -- please open up PRs with your ideas or any issues you encounter
trying to implement them.

You can also try out Tux[7] <https://github.com/sapio-lang/tux>, an
experimental GUI, to inspect, simulate, and interact with smart contracts.
You can see the Congestion Control Tree mentioned earlier loaded in Tux
below[8] <https://i.imgur.com/pg5SqfH.png>:

This is still early work-in-progress software, so tread lightly and use
regtest. Enough of the components work today that it was appropriate to
share now and invite more developers to contribute or otherwise support the
project.

Sapio is developed free and open source for all bitcoiners by Judica.org
(my organization).

Thank you to all who have helped reach this milestone of the first mainnet
Sapio contract, including Ryan Grant, BitMEX, ACINQ, Delphi Digital,
Backend Capital, my github sponsors https://github.com/sponsors/jeremyrubin,
and numerous other supporters both fiscal and technical. I also want to
highlight the excellent work done on Miniscript and the rust-bitcoin
ecosystem, the foundation upon which Sapio rests.

[0] https://github.com/sapio-lang/sapio
[1] https://utxos.org
[2] https://learn.sapio-lang.org
[3] https://judica.org/blog/sapio/
[4] https://utxos.org/analysis/bip_simulation/
[5] https://gist.github.com/JeremyRubin/1374f0916bfdef0bd36bc10d73852886
[6]
https://github.com/sapio-lang/sapio/tree/master/sapio-contrib/src/contracts
[7] https://github.com/sapio-lang/tux
[8] https://imgur.com/pg5SqfH

Eager for you feedback,

Jeremy

--
@JeremyRubin <https://twitter.com/JeremyRubin>
<https://twitter.com/JeremyRubin>