Now that the Taproot upgrade has been added to the network, it brings with it several feature sets to Bitcoin. One of them is additional smart contract functionality. If you’ve hung around the crypto space, you’ve probably heard this term thrown around. These other smart contract platforms use them for things like making tokens, NFTs and DEFI protocols.
Does this mean shitcoin scams, NFT marketplaces, and Dex’s are coming to Bitcoin? It could be, Bitcoin is an open network, and people can build whatever they want leveraging the system and growing set of tools. However, getting the market to accept your product is an entirely different challenge.
In the shitcoin space, people realise their coin doesn’t have value, so they’re willing to swap casino chips for other casino chips. In the Bitcoin world, people realise Bitcoin is money and won’t give it up for something silly. This reduces the incentive to create shitcoin projects on top of Bitcoin, but it doesn’t mean people won’t try.
So if most of the smart contract use cases aren’t all that valuable, why would people want it on Bitcoin? You see, a tool is only as good as the person holding it with Bitcoin; smart contracts take on a different role.
Smart contracts is a bit of a confusing term, as these contracts aren’t smart, nor are they contracts, but when the marketing sounds good, I guess you stick with it.
What is a Bitcoin Smart Contract?
A smart contract is a digital agreement that can automatically execute and when predefined criteria are met. For example, a smart contract might specify that bitcoin should be automatically sent from one user to another after an inevitable time delay.
The example given is relatively simple, but there are, of course. In contrast, there are smart contracts with more complex requirements which include multiple conditional criteria.
How Bitcoin makes use of Smart Contracts
The Bitcoin network supports a range of smart contracts using its powerful scripting language, called “Script”. The scripting language allows users to establish criteria for their bitcoin to be transferred. When a smart contract is created using Bitcoin transactions, the contract is required to lock specific amounts of bitcoin for settlement.
A user or another party specified in the contract must satisfy these criteria to spend the bitcoin locked to the script. In this way, all Bitcoin transactions are technically smart contracts by this broad definition.
In Bitcoin Smart Contracts, the spending criteria is called the scriptPubKey, which is a locking script. The script that satisfies the requirements is called the ScriptSig or ScriptWitness, which depends on whether the input uses SegWit or not.
Bitcoin Script and Turing Completeness
Script has proven helpful for powering the Bitcoin network for over a decade, but one criticism of Bitcoin’s version is that it is not Turing Complete as in the case of other Smart contract implementations on other chains.
The lack of a Turing Complete implementation means certain feature sets cannot be applied, such as allowing for logical loops. This feature keeps the Bitcoin network safe from Denial of Service (DoS) attacks, which have plagued other cryptocurrency networks.
Bitcoin developers will always make the security trade-off when comparing it to additional utility as not to risk the value locked in the chain for any additional feature set.Â
Types of Bitcoin Smart Contracts
P2PKH is a popular Bitcoin script that allows bitcoin to be sent so only the owner of the corresponding private key can spend the bitcoin.
On a technical level, P2PKH scripts establish the specific requirement that to spend bitcoin, a user must provide an ECDSA signature that matches the public key whose hash is specified by the script.
Since a valid signature can only be created by the owner of the private key corresponding to the public key hash, the bitcoin belong exclusively to the private key owner.
Bitcoin Smart Contracts options.
Pay-to-Public-Key-Hash is one of the more straightforward bitcoin smart contracts, but its utility and simplicity make it the most popular.
Multi-signature scripts
While P2PKH scripts only require a single signature, MultiSig scripts can require any number of signatures, optionally belonging to any number of users.Â
The MultiSignature scripts work as follows.
A list of n public keys and a number m, less than or equal to n, are specified. The bitcoin locked to this script can only be spent if m signatures are provided, each corresponding to one of the n public keys listed.
The design is known as “m-of-n MultiSig”.
One common MultiSig setup is 2-of-3, which requires two signatures from a group of three public keys. This allows three parties to hold money cooperatively while ensuring that no single person or majority can steal the funds.
The 2-of-3 MultiSig is currently used as a trust-minimised escrow for Bitcoin DEFI or P2P exchanges.
Time-locked Bitcoin transactions
Bitcoin transactions can be time-locked, which allows Bitcoin to be spent after a certain time has elapsed. Time locks can also be used as part of the locking scripts to change requirements for spending.
For example, it can be combined with a Mulisig set up which requires a condition were three signatures need to sign to spend the bitcoin before a certain time.
This implementation fallback options possible, ideally preventing a loss of funds if an issue or contesting the validity of the agreement comes into question.
Pay-to-Script-Hash (P2SH)
Arbitrarily complex scripts have been made possible by the Pay-to-Script-Hash (P2SH) standard, which was extended to include P2WSH as part of the SegWit upgrade.
P2SH and P2WSH smart contracts allow bitcoin to be sent to the hash of any script, including any of the above examples. This design minimises the cost of sending bitcoin to a complex smart contract and maintains greater privacy until the bitcoin is spent.
Taproot enabled Bitcoin Smart contracts.
Bitcoin’s Taproot upgrade will introduce a new script type called Pay-to-Taproot (P2TR), which will unite the functionality of P2PKH and P2SH scripts, allowing bitcoin to be sent to both a public key and arbitrary scripts.Â
While P2SH and P2WSH allowed bitcoin to be sent to a single script, P2TR uses Merkelized Alternative Script Trees (MAST) to enable bitcoin to be sent to up to 2^128 different, arbitrary scripts.
This allows for more versatility as any one of these scripts can be set and satisfied to spend a bitcoin transaction.
Bitcoin’s Taproot upgrade gives Bitcoin users a significant increase in optionality to construct complex smart contracts on the bitcoin chain.Â
Smart Contract layers on top of Bitcoin
All of the Smart Contracts mentioned above execute on Bitcoin’s blockchain as regular Bitcoin transactions. Using the new schnorr signatures all transactions will look similar on the base chain, which provides additional privacy.Â
Smart Contracts can be created on the base chain and additional layers, such as the Lightning Network and Liquid Network.
Smart contract implementation will take time.
The new scripting set and combination with previous scripting features will bring forth new business models and functionality directly to the Bitcoin network. It will take time for nodes to update to validate taproot transactions. It will take time for wallets and applications to play around and implement these scripts.
So don’t expect to see a brand new ecosystem overnight. Still, the building blocks are here for creative developers and entrepreneurs to build new robust feature sets that leverage the Bitcoin network and supported side chains.