<p>The two have very little to do with one another.</p>
<ul>
<li>Minsc is a scripting tool for defining keys.</li>
<li>Sapio is a compiler framework for defining covenant contracts.</li>
</ul>
<p>You could, if you wanted, use Minsc from Sapio as a plugin for defining the unlocking conditions in any given Sapio program path, but you could not use Sapio inside of Minsc in the same way.</p>
<p>Sapio does not compile down to miniscript; it has it's own compiled object format that <em>contains</em> miniscript. There is other stuff in there as well.</p>

CC BY-SA 4.0
2021-08-04T16:27:49.653Z
A covenant contract has to produce a script that goes onchain. I get that OP_CTV adds an extra opcode to Script (other than that Script stays the same). But at least in theory in a world where OP_CTV has activated on mainnet Miniscript could be extended to support OP_CTV? Just like Miniscript will hopefully be extended to support Taproot?
Michael Folkson
CC BY-SA 4.0
2021-08-04T16:38:27.817Z
Perhaps as Miniscript only encodes a subset of Script you've made the decision to bypass Miniscript as you want the full Script functionality... but it is impossible to bypass Script. Somehow a Sapio contract needs to turn into Script.
Michael Folkson
CC BY-SA 4.0
2021-08-05T17:28:58.810Z
yes, miniscript would have CTV support -- you can see i've added it to my fork of rust miniscript. it's missing the point though. think of miniscript/minsc as generally being focused on the problem of "compiling a single function that has the API `bool spend(SigningData, Utxo)`. Sapio is focused on the problem of `either<txn, bool> spend(SigningData, Utxo)`. The functions are fundamentally different types. miniscript/minsc tell you true/false, sapio tells you either a specific txn OR anything OR not valid.
Jeremy Rubin
CC BY-SA 4.0
2021-08-05T17:29:49.443Z
so what you're missing is that sapio encodes state transitions and unlocking conditions, whereas minsc/miniscript just encodes the specific unlocking conditions. of course you could consider the state transitions to be part of the unlocking condition, but that's not what miniscript or minsc have been designed to think about.
Jeremy Rubin
CC BY-SA 4.0
2021-08-08T12:24:02.380Z
So across multiple transactions (multiple locking and unlocking) rather than just a locking script within a single UTXO? State transitions can only really happen across transactions in Bitcoin so it must be that.
Michael Folkson
CC BY-SA 4.0
2021-08-09T17:04:46.707Z
exactly; sapio lets you author transactions and scripts, not just scripts. the transactions are embedded in the scripts of course through ctv
Jeremy Rubin
CC BY-SA 4.0
2021-08-04T15:06:55.730Z
2021-08-04T15:06:55.730Z
Jeremy Rubin
<p>Both <a href="https://bitcoin.stackexchange.com/questions/98357/what-is-the-relationship-between-the-minsc-language-and-policy-language">Minsc</a> and <a href="https://bitcoin.stackexchange.com/questions/106850/is-there-anything-specific-to-the-design-of-the-sapio-language-that-makes-it-wel">Sapio</a> are high level scripting languages that compile down to Miniscript. What are the differences between the two? When should I use one over the other?</p>

<minsc><sapio><bip119-checktemplateverify>
What are the differences between the Minsc and Sapio high level scripting languages?
Michael Folkson
# What are the differences between the Minsc and Sapio high level scripting languages?

(Asked by: username_0 on 2021-06-08)

Both [Minsc](https://bitcoin.stackexchange.com/questions/98357/what-is-the-relationship-between-the-minsc-language-and-policy-language) and [Sapio](https://bitcoin.stackexchange.com/questions/106850/is-there-anything-specific-to-the-design-of-the-sapio-language-that-makes-it-wel) are high level scripting languages that compile down to Miniscript. What are the differences between the two? When should I use one over the other?

**Tags:** minsc, sapio, bip119-checktemplateverify


---

## 1 answers

### Answer by username_1 on 2021-08-04. Score: 1 | Accepted answer

The two have very little to do with one another.

* Minsc is a scripting tool for defining keys.
* Sapio is a compiler framework for defining covenant contracts.

You could, if you wanted, use Minsc from Sapio as a plugin for defining the unlocking conditions in any given Sapio program path, but you could not use Sapio inside of Minsc in the same way.

Sapio does not compile down to miniscript; it has it's own compiled object format that *contains* miniscript. There is other stuff in there as well.

> **Comments:**
> **username_0**: A covenant contract has to produce a script that goes onchain. I get that OP_CTV adds an extra opcode to Script (other than that Script stays the same). But at least in theory in a world where OP_CTV has activated on mainnet Miniscript could be extended to support OP_CTV? Just like Miniscript will hopefully be extended to support Taproot?  
> **username_0**: Perhaps as Miniscript only encodes a subset of Script you've made the decision to bypass Miniscript as you want the full Script functionality... but it is impossible to bypass Script. Somehow a Sapio contract needs to turn into Script.  
> **username_1**: yes, miniscript would have CTV support -- you can see i've added it to my fork of rust miniscript. it's missing the point though. think of miniscript/minsc as generally being focused on the problem of "compiling a single function that has the API `bool spend(SigningData, Utxo)`. Sapio is focused on the problem of `either<txn, bool> spend(SigningData, Utxo)`. The functions are fundamentally different types. miniscript/minsc tell you true/false, sapio tells you either a specific txn OR anything OR not valid.  
> **username_1**: so what you're missing is that sapio encodes state transitions and unlocking conditions, whereas minsc/miniscript just encodes the specific unlocking conditions. of course you could consider the state transitions to be part of the unlocking condition, but that's not what miniscript or minsc have been designed to think about.  
> **username_0**: So across multiple transactions (multiple locking and unlocking) rather than just a locking script within a single UTXO? State transitions can only really happen across transactions in Bitcoin so it must be that.  
> **username_1**: exactly; sapio lets you author transactions and scripts, not just scripts. the transactions are embedded in the scripts of course through ctv  

---

