Trust Machines Logo

What are Bitcoin Smart Contracts and How Do They Work?

Written by undefined @
Read Time 7 min
A graphic with multiple screens, highlighting Bitcoin smart contracts.
Table of Contents
Share This Article

While most people associate Bitcoin with money, it has another important use case that is less commonly known - smart contracts.

Smart contracts are the foundation of building on Bitcoin. They enable trustless, self-executing agreements that do not require facilitation from a central authority. 

Right now, Bitcoin capital is predominantly idle. Roughly 76% of all Bitcoin supply remains illiquid, with no history of transacting. There is a massive opportunity in unlocking a new level of Bitcoin productivity through the expansion of smart contracts. By programming more smart contracts into the network, Bitcoin could accelerate its mainstream adoption as both a store of value and a financial services layer.

In this article, we will uncover the world of Bitcoin smart contracts, and discuss how they have evolved to host a vast ecosystem built on top of the network.

Does Bitcoin Have Smart Contracts?

Bitcoin does have simple smart contracts on its mainchain, in addition to more complex smart contract functionality that is programmed with Bitcoin layers.

The reason Bitcoin is not normally brought up in regards to smart contracts is because its limited scripting language makes it inferior to today’s standard in terms of blockchain programmability. However, as we will discuss later, layered solutions have emerged in more recent years to bring Bitcoin’s smart contract functionality up to par with leading blockchain ecosystems.

How Do Smart Contracts Work on Bitcoin?

Smart contracts are either created on the Bitcoin mainchain, or on a layered solution. Here, we will break down all the different ways Bitcoin smart contracts are developed.

Smart Contracts on the Bitcoin Mainchain

Bitcoin’s scripting language, Script, is fairly simple, which makes complex smart contracts rather difficult to deploy on the base layer. Since its inception, Bitcoin was designed to be simple and relatively unmodified to ensure the blockchain’s integrity and durability. While upgrades to the protocol occur periodically, they are not meant to transformatively change the blockchain and only provide minor improvements around the edges. 

That being said, Bitcoin still has a number of basic smart contract functions at its base layer.

Pay-to-Public-Key-Hash (P2PKH)

Pay-to-Public-Key-Hash is the common contract used for Bitcoin transactions. Ultimately, it is the most common contract on the chain. This script creates contracts that are executed by a public key, plus a signature created by the corresponding private key.

Multi-signature (Multisig)

Multi-signature is a type of Bitcoin address that requires multiple parties to approve a transaction before it can be completed. These smart contracts are most commonly used to execute an agreement between parties where a predefined number of signatures must be gathered to release funds or perform some other action.

Hashed Time Lock Contract (HTLC)

A Hashed Time Lock Contract is a conditional Bitcoin transaction with time-bound contingencies. These time constraints are hardcoded and BTC is only released at a specific time and date (or block). If certain requirements within the contract are not met before a preset deadline, the transaction is canceled.

Discreet Log Contracts (DLCs)

DLCs utilize oracles to execute trustless peer-to-peer transactions. These oracles are able to evaluate outcomes of real-world events, and provide that information on-chain for the Bitcoin smart contract. A DLC is most often used when two involved parties commit to a monetary agreement (or bet) based on future outcomes.

Pay-to-Taproot (P2TR)

Pay-to-Taproot is a script for sending Bitcoin which introduces Merkle Trees and Schnorr Signatures. These transactions offer better security, lower transaction fees, and more flexibility. This form of contract was recently implemented as a result of the Taproot Upgrade.

Smart Contracts on Bitcoin Layers

Bitcoin layers are unique in that they can introduce new features to the network, without making any modifications to the mainchain. Rather than altering Bitcoin code, innovations and other experimental developments can be introduced without any modifications to the Bitcoin blockchain itself. This way, the core of Bitcoin can always remain simple, and unaffected by what is being built on top.

All Bitcoin layer transactions ultimately settle on the Bitcoin base layer. This means that the history of every transaction will be written into Bitcoin’s ledger, which is agold standard for security, immutability, and durability within blockchain. The degree of verification is what sets the blockchain apart from any other network. To alter a Bitcoin layer transaction, you would need to alter a mainchain transaction - which is nearly impossible.

Overall, Bitcoin smart contracts that execute on layers have a few key advantages.

Greater programmability. Smart contracts on layers overcome the limited capabilities of Bitcoin’s scripting language by accessing its own global state. By having their own fully expressive smart contracts and gas tokens, layers can broaden the possibilities for what can be built on top of Bitcoin.

Higher scalability. Deploying smart contracts on scaling solutions means that transactions can be processed remarkably faster. Currently, the base layer can only handle about 5-7 transactions per second. Bitcoin layers can bundle transactions before they are sent to the mainchain for final settlement. This dramatically increases Bitcoin’s throughput and its viability as a scalable network with millions of daily transactions.

Improved efficiency. Improved scalability goes hand in hand with faster transactions and cheaper costs. Shorter block times make for quicker confirmation, while the cost of transacting on a Bitcoin layer is significantly reduced compared to the mainchain. Moreover, layered transactions reduce clutter that occurs at the base layer and improves the performance of the entire network.

Examples of Bitcoin Smart Contract Platforms

With more capable smart contracts, developers are able to build decentralized applications (dApps) - an essential part of Web3 infrastructure. Here are some of the platforms for creating Bitcoin-powered smart contracts.


Stacks is a blockchain designed to bring smart contracts and decentralized applications to Bitcoin.

Stacks developers write smart contracts in Clarity, a programming language specifically for Stacks. Clarity is a decidable language, which optimizes for predictability and security when developing new smart contracts. Moreover, it is easy for developers to understand with full certainty what a contract can and cannot do before it is even deployed.  

A novel feature of Clarity is that it is able to read Bitcoin state, and can include Bitcoin-based logic. This visibility into Bitcoin is extremely advantageous, and allows for Stacks smart contracts to react and trigger based on events occurring directly on Bitcoin’s blockchain.

Thanks to smart contracts, Stacks has cultivated a growing ecosystem of dApps for Bitcoin, including DeFi protocols, NFTs, DAOs, and altcoins.


RSK (Rootstock) is a sidechain that enables smart contract functionality for Bitcoin through its EVM-compatibility. In other words, developers are able to seamlessly port smart contracts and dApps from Ethereum over to the RSK blockchain. RSK supports all Ethereum smart contract programming languages, which includes Solidity (the most common), Julia, and Vyper.

Many of RSK’s smart contracts are geared towards its decentralized finance ecosystem of digital wallets, asset swaps, lending protocols, stablecoins, and more.

Other Bitcoin Layers with Smart Contracts

Additionally, there are other Bitcoin layers that do not have complete, readily accessible smart contract platforms, but still utilize smart contracts on top of the mainchain.

Lightning Network

Lighting Network, a layer 2 scaling solution, uses smart contracts to facilitate fast and cheap peer-to-peer Bitcoin transactions. These smart contracts are multi-signature, HTLCs, or DLCs, which are simple smart contracts adopted from the mainchain.

Liquid Network

Liquid Network is a Bitcoin sidechain for asset issuance, but is planning to introduce smart contract functionality in a future update.

Internet Computer (ICP)

Internet Computer Protocol is a blockchain network that has a cryptographic integration with Bitcoin. ICP uses Mokoto, which is its own programmable language. Through Motoko, developers can create smart contracts (also referred to as “Canisters”) to transfer native BTC and build decentralized applications for the Bitcoin ecosystem.


Mintlayer is a new Bitcoin sidechain for the issuance of tokenized assets, smart contracts, and financial applications. The layer uses its own scripting language and is compatible with the mainchain and the Lightning Network.


FastKitten is a proposal that attempts to add smart contracts to Bitcoin via off-chain computations. The protocol introduces some elements of centralization as it operates under a central intermediary who is responsible for publishing the final state of the ledger once the agreements within the smart contract have been met.

Programming Transactions to Expand the Bitcoin Economy

While Bitcoin is primarily known as a decentralized digital currency, it is also a platform for executing smart contracts.

Being a highly decentralized, secure, and durable blockchain, Bitcoin is ripe to serve as the foundation for more on-chain economic activity.

Since the smart contract capabilities of Bitcoin’s blockchain are relatively basic, layered solutions have opened the door to unprecedented utilization for BTC capital. Complex Bitcoin smart contracts are still relatively new blockchain technology, but they have already shown great progress. Platforms like Stacks and RSK are critical for the future of fully expressive smart contracts that are native to the network.

Bitcoin has already made its presence known in the world of digital assets, and could soon emerge as a top ecosystem for smart contracts, decentralized applications, and the future of Web3 infrastructure.