Back

Miniscript Resources

Essential free resources to learn about Miniscript, the framework that enables intuitive Bitcoin Smart Contracts

Rob Hamilton

October 24, 2023

When Satoshi Nakamoto invented Bitcoin in 2009, it encompassed more than just the data structure of a ‘Blockchain,’ the peer-to-peer network, or the currency of bitcoin itself. Satoshi also invented a programming language called Bitcoin Script. Bitcoin Script is a stack-based, Forth-like programming language used in the Bitcoin protocol to specify the conditions under which a transaction output can be spent. In other words, it sets the rules governing your money.

Thus far in Bitcoin’s existence, transactions have been kept to relatively simple rules around signature checks. This is most commonly seen as a single signature, where one key is able to move the Bitcoin. For larger sums of money or corporate settings, multiple signatures are utilized, where a majority of a set of keys must sign to move the money. Bitcoin Script is executed via a series of OP Codes, which are explicit instructions on how to interact with the data. In these examples, they are achieved by using OP_CHECKSIG & OP_CHECKMULTISIG respectively. Such transactions constitute the majority of network activity on Bitcoin.

However, Bitcoin Script can accomplish much more, including flow control (if/else) as well as boolean logic (and/or) that you’d find in other programming languages. Additionally, you can leverage timelocks, which introduce time passed as a security condition to be satisfied, as well as Hash Locks, allowing you to provide some data instead of a signature to satisfy a condition. Each of these concepts individually enables an opportunity for more robust Bitcoin Smart Contracts that can be executed within Bitcoin today, all without having to upgrade the network. So, why hasn’t this been implemented at scale yet?

Its unintuitive nature makes it difficult to analyze Bitcoin Script, making it challenging to reason if it will execute the way you intend it to. Moreover, Bitcoin Scripts must be constructed in such a way that a malicious third party cannot take an unconfirmed transaction and malleate it to redirect funds elsewhere. In summary, there are a lot of ways an arbitrary Bitcoin Script can go wrong.

After a year of development, Miniscript was announced at the end of 2019 on Blockstream’s blog. Pieter Wuille & Andrew Poelstra were tackling all of the previously mentioned problems of Bitcoin Script. Miniscript is a subset of Bitcoin Script, which most importantly means it can be used in Bitcoin today without a fork. Additionally, Miniscript provides a framework for human-readable analysis of a proposed advanced Bitcoin Smart Contract. Miniscript is also composable, allowing for multiple Miniscript constructions to be combined with one another, operating much like Lego bricks. It also optimizes the entire proposed script to use as few bytes as possible. Miniscript outperformed the official Bolt 3 Spec in executing Lightning Network transactions more efficiently.

Over the past year, I’ve delved into how Miniscript represents a paradigm shift in Bitcoin security. Throughout that time, I’ve gathered resources that have helped grow my understanding of how Miniscript works, which I intend to share.

Miniscript Resources

Videos:

Articles:

Podcasts:

Code References:

Contact Us

Always here to help

To request general assistance, you should contact AnchorWatch Inc, at: