Smart contracts were made famous by the Ethereum (ETH) network, which offers Turing-complete smart contracts that enable the development of decentralized products and services. What not everyone may be aware of, however, is that smart contracts also exist on Bitcoin (BTC).
Read on to learn about Bitcoin smart contracts and the different projects that are pushing smart contract functionalities on top of the Bitcoin network.
Smart contracts on Bitcoin: What’s possible with Script?
A smart contract is a coded agreement between two or more parties that is automatically carried out when predefined criteria are met.
For instance, a Bitcoin smart contract can state that a BTC payment should be sent from one person to another once an agreeable task has been completed.
The Bitcoin network supports various types of smart contracts via Script, the scripting language that it uses.
With Script, users are able to create different criteria on how their BTC is utilized. Additionally, scripts can also lock certain amounts of BTC to specific bitcoin transactions, where users must be able to meet those standards before they can spend the BTC locked to that script.
Examples of Bitcoin smart contracts
In over the ten plus years that Script has been used in the Bitcoin protocol, it has proven to be a useful scripting language supporting a wide range of Bitcoin smart contracts, such as the simpler pay-to-public-key-hash (P2PKH) to more complex ones like multi-signature scripts, pay-to-script-hash (P2SH), and time-locked transactions.
Let’s take a look at the most common types of scripts Bitcoin uses.
A P2PKH is a simple and popular script that enables users to send BTC to a bitcoin address. It’s the most basic form of making a transaction on the Bitcoin network.
A time-locked bitcoin transaction is a type of smart contract that controls the spending of bitcoin until after a certain period. Time locks are very popular and are used in many Bitcoin smart contracts.
For instance, a time-locked script can dictate that three signatures are needed in order to spend a given amount of bitcoin before a specific period, after which only one signature will be needed. Time-locked transactions are excellent as they help prevent the loss of funds.
Unlike P2PKH scripts that require one signature, a multi-signature or multisig script can require several signatures belonging to several users. Multi-signature scripts work by creating an order where N public keys are registered in the script and a number M is needed to sign off to unlock the funds.
That means that the amount of bitcoin locked to this type of script cannot be spent unless M signatures are issued and each of them needs to match one of the N public keys conditions. This concept is known as M-of-N multi-signature. In this case, N refers to the total number of public keys listed and N is the minimum number of signatures needed to validate the transaction.
Pay-to-script hash (P2SH)
The Pay-to-Script Hash (P2SH) is a standard credited for enabling the creation of complex scripts. The P2SH script doesn’t work independently. Instead, it includes the P2WSH script, which came to be after the SegWit upgrade. The two scripts work together to make it possible for bitcoin to be sent to the hash of any script.
Bitcoin smart contract layers: What’s possible on top of bitcoin
Due to the limitations of Bitcoin’s scripting language, Bitcoin developers have worked on new layers on top of the Bitcoin blockchain to enable more complex smart contract development for Bitcoin-powered applications.
The most notable layers for smart contracts built on top of Bitcoin include Rootstock, Liquid, Stacks, Lightning, and RBG. Let’s take a brief look at each of the five projects.
Rootstock (RSK) is a smart contract platform that includes a Turing-complete virtual machine to connect to the Bitcoin blockchain.
The Turing-complete smart contracts provided by RSK is a concept that was first proposed by computer scientist Nick Szabo back in 1993. And because RSK works as a Bitcoin sidechain, it enables developers to build decentralized applications secured by the Bitcoin network without being limited by Bitcoin’s scripting language.
Bitcoin DeFi applications are already operating on RSK, powered by RSK Smart Bitcoin (rBTC). rBTC is pegged to BTC 1:1 and created by sending BTC to a multisig address managed by the RSK PowPeg (2-way peg protocol).
The Liquid Network was launched in 2018 by major blockchain technology company Blockstream. Although it has attracted relatively moderate usage since it was established, it has been able to provide transactions geared towards the needs of brokers, exchanges, financial institutions, and market makers.
As a Bitcoin sidechain, the Liquid Network is designed for business needs and not necessarily for an average Bitcoin user. The Liquid Network also uses Liquid Bitcoin (L-BTC) as an asset.
As a Bitcoin smart contract layer, it gives users the ability to provide assets in the form of tokens such as stablecoins. Additionally, Bitcoin NFTs can also be issued on the Liquid Network.
Stacks is a Layer 1 blockchain that is connected to Bitcoin by its consensus mechanism known as proof-of-transfer (PoX). It leverages Bitcoin’s economic power, security, and stability to bring smart contracts to Bitcoin.
For apps built on Stacks given that it’s linked to the Bitcoin blockchain, the Bitcoin layer always acts as the final layer, while the smart contract is built on the Stacks chain.
Similar to other layers, Stacks addresses the utility and scalability issue of the Bitcoin network, while pushing for the development of a decentralized digital economy secured by Bitcoin.
The Lightning Network (LN) was first proposed by Joseph Poon and Thaddeus Dryja back in 2015. It is a second-layer technology that utilizes payment channels to boost the Bitcoin network’s capacity to carry out transactions in an efficient manner.
LN relies on multisig transaction smart contracts, called hashed time-locked contracts (HTLCs), to enable lightning-fast bitcoin transitions with next to no fees.
The Lightning Network was designed to help take away transactions from the main blockchain network (off-chain), thus helping to lower the transaction fees and decongesting the Bitcoin blockchain.
RGB is a collection of protocols that provides smart contracts for Bitcoin and the Lightning Network. It’s client-sided and its smart contracts system runs on layers two and three of the Bitcoin ecosystem.
RGB, unlike other Bitcoin smart contracts that exist, doesn’t require the generation of a token. Instead, it aids in the separation concept of smart contract issuer, state evolution, and state owners. As a smart contract system, RGB makes use of the blockchain as a state commitment layer and Bitcoin script as an ownership control system. The evolution of its smart contract is determined by off-chain schema.
While the Bitcoin ecosystem doesn’t have anywhere near the number of decentralized applications as leading smart contract chains like Ethereum, a growing number of Bitcoin developers are dedicating their time and energy to building a decentralized economy on top of the most secure blockchain in the world.
– Play-to-Earn Bitcoin Games: How Lightning Network Enables Gamers to Earn Sats
– How to Buy Bitcoin Without an ID in 2022