Blockchain Smart Contracts Introduction
Imagine a world where you can do business without trusting anyone – a world where you don’t fear that the other party will not deliver on their commitment. A world that has systems that will execute contracts as they have been agreed upon with no possibility of default; where you don’t have to rely on tedious court proceedings or other third parties to decide upon the fate of your transactions.
This is the promise of smart contracts on the blockchain. And it is slowly becoming a reality.
This “trustless” reality begun to unfold on the 3rd of January 2009 when Satoshi Nakamoto successfully exchanged value without using government-issued money through a system he created and called Bitcoin. He has proven that a peer-to-peer decentralized value exchange can work and that newly-created network slowly started changing the world. But it is not bitcoin per se that changed the world. Nakamoto has successfully intertwined four important technologies that made the creation of bitcoin and other cryptocurrencies possible. These are the bitcoin protocol, consensus rules, proof-of-work, and blockchain.
The bitcoin protocol enables computers to communicate with the peer-to-peer bitcoin network. Consensus rules enable the growth of the bitcoin network without a central authority. Proof-of-work gives uncompromising security to the network. And the blockchain enables the transparency and immutability of transaction records. These created a system that made possible the exchange of value between and among peers without trusting any centralized intermediary.
In this article, we focus on the importance of blockchain and smart contracts in creating a world where transactions are completely automated and trustless.
The Blockchain Ecosystem 101
The blockchain is a recording system combined with other novel technologies, created the fundamental technology behind bitcoin and other cryptocurrencies. This unique record-keeping model accumulates transactions per block which are then cryptographically-linked creating a “chain of transaction blocks”.
To simplify, let’s assume you are one of the several thousand record-keepers (nodes) in a cryptocurrency network. As a record-keeper, you maintain a copy of the records (blockchain) that have been checked by verifiers (miners). The verifiers authenticate and accumulate pieces of papers containing various transactions from a pool of unconfirmed transactions. Subsequently, verified transactions are placed in a box (block). The verifiers then compete in a complex mathematical race staking their computing power in order to win the right to place their box into the blockchain (i.e. “proof-of-work”). Once a verifier wins the race, the winner’s box of transactions is officially entered in the blockchain and is rewarded freshly generated currency (e.g. bitcoins). All record-keepers in the network, including you, then add the winning verifier’s box of verified transactions to the blockchain. Thus, the blockchain is a collection of verified transactions.
As record-keepers, you need to ensure that the blocks are in order prior to adding it to your copy of the blockchain. It may seem a very tedious and time-consuming process but all of these have been properly compiled in a rulebook called consensus rules and implemented through a protocol that makes it easy for computers to efficiently interact with the network and do the verification activities.
Blockchain: trustless and immutable
As you may glean from above, the blockchain is a major component of a highly-secure and decentralized system. The system is highly secured because transactions have to undergo several layers of verification by independent parties (miners and nodes) who contribute significant amounts of computing power and energy in order to verify and secure the network. It is also decentralized because there are potentially thousands of participants (peers) that make the system work without a single, central authority or organization that makes decisions for the entire ecosystem. This is the reason why implementations of public blockchains are often called “trustless” since you don’t have to trust anybody; instead, you put your trust in the entire network.
The blockchain is also considered “immutable” – meaning it is permanent, it cannot be changed. Well, it’s not totally unchangeable, but it will require enormous amounts of computing power just to be able to make changes in the blockchain. This is because each block is linked to a chain that contains accumulated proof-of-work. If you wish to change a transaction, say made last week, you need to have more than half of the equivalent computing power spent by the miners last week in order to have it changed. Currently, the computing power required to make this possible is around 20 million terahashes per second (TH/s). This will require you to set up an entire warehouse of specialized mining equipment called application specific integrated circuits (ASIC) and spend millions of dollars’ worth of electricity. Just imagine if you want to change a transaction that is more than one week old – the cost would be so staggering that it’s better to just leave it as is. Basically, as more blocks are added on top of a block, the transactions in that block become difficult to modify. The system has been programmed to add a block every 10 minutes.
Blockchain is not Bitcoin
When people talk about bitcoin, they sometimes talk about the blockchain as its underlying technology. It is partly true because blockchain is one of the components of the core technology that makes bitcoin possible. This association usually leads people to conclude that blockchain can only be used to support bitcoin or other cryptocurrencies that are used as mediums of exchange.
The application of blockchain technology in the various digital currencies like bitcoin, litecoin, and monero is actually its first successful implementation. However, blockchain as a record-keeping mechanism is not limited to accounting for currency-related transactions. And this was subsequently proven by a young Canadian programmer named Vitalik Buterin.
What is a smart contract?
In 2015, Buterin realized that the technology behind bitcoin has so much more potential. He then started building a new blockchain that not only can be used as a medium of exchange but as a platform for building applications. He envisioned a blockchain that can be used to share computing power – a decentralized application platform. At the core of this new blockchain, which is now known as Ethereum, is the concept of “smart contracts”.
Smart contract is not a totally new concept. It was first introduced by programmer and cryptographer Nick Szabo in 1993. He described it as a “digital vending machine” where an input, any digital assets or representation of value, is placed in the machine. Once the machine verifies the input, it automatically drops something in exchange for the value placed. In this case, it may be a tangible or intangible good (e.g. a soda or subscription). In this illustration, the exchange of value is automatically done by the machine (smart contract) without human intervention.
A smart contract is similar to a traditional signed contract wherein value is exchanged between parties but without the services of intermediaries, such as lawyers. It is then executed digitally by a computer program. So basically, smart contracts digitally facilitate, enforce, settle and/or verify arrangements between parties exactly as programmed. This can significantly reduce the costs of creating, executing and litigating contracts since you don’t have to pay a lawyer to ensure that the other party will hold their end of the contract or blindly trust the other party to fulfill their obligation.
This is the beauty of smart contracts run on public blockchains: you don’t need to trust the other party – you trust the entire network instead. If the other party fails to deliver, the smart contract automatically returns your payment and possibly imposes a programmed punishment on the other party. Furthermore, smart contracts that run on public blockchain have no downtimes, cannot be censored, can easily be verified (trackable) and are essentially irreversible (immutable).
Smart contracts on Ethereum
The bitcoin blockchain made basic smart contracts possible. Although value can be exchanged between parties using consensus rules, time functions, multi-signatures and hash functions, most of these contracts are limited to currency use cases.
In contrast, Buterin’s creation, ethereum, was specifically designed to build decentralized applications using smart contracts. Ethereum’s programming language called “solidity”, opened up new opportunities for programmers to write their own programs using the ethereum blockchain’s computing power. These developers can pay for the use of ethereum’s blockchain in “ether”, the ethereum’s native currency.
One of the most common use cases of smart contracts on ethereum is crowdfunding. In an initial coin offering (ICO), the crypto-world’s way of crowdfunding using cryptocurrencies, developers who want to pursue the development of their apps can easily raise funds using smart contracts.
Investors in an ICO contribute cryptocurrencies, usually bitcoin and ether, in exchange for a project’s “tokens”. These tokens are created using smart contracts. Often, the tokens will only be issued if certain project criteria are met, such as meeting a “soft cap” or the minimum investment raised, in order to proceed with the project. If the soft cap is not met, the smart contract automatically returns all bitcoin and ethers contributed by the investors. Else, the equivalent number of tokens will be released to the investors.
A new age of smart contracts
We are only beginning to see the possibilities of using smart contracts to solve existing real-world problems. The current database systems implemented by central authorities have had pervasive issues that smart contracts and blockchain can solve.
Smart contracts on public blockchains have started disrupting the current financial ecosystem making banks less relevant with the use of smart contracts in escrow and settlement services. Medical records can be streamlined with healthcare service providers, insurance companies, and pharmacies which will have relevant access to your records without compromising your ability to maintain control over the management of these records. You can create a will using a smart contract and the distribution of your assets will be automatically executed in accordance with your intentions only when your death is confirmed.
Land titles and gun records that are recorded on a public blockchain can easily be transferred between a buyer and seller using a smart contract without spending much for the transfer. Governments or even smaller organizations can use smart contracts in voting systems in order to ensure accuracy and transparency that will preserve the integrity of the elections. CPU owners can earn extra cash by lending their idle computing power and storage to those who need it without going through a central electronic marketplace.
There are more applications of smart contracts on blockchains that are currently being tested and it is certain that much more will be discovered soon. We are once again seeing a rush of interest (and funds) towards blockchain and smart contract projects similar to the time when internet usage started to grow in the 1990s. Just like the thousands of internet and mobile projects that have been presented to the public, many of these blockchain projects will also undoubtedly fail. Because of these failed projects, many famous people will brand blockchain as a “complete failure”. Blockchains and smart contracts have many imperfections and disadvantages. However, just like the internet which was also once branded as a complete failure, developers will surely find ways to reduce these issues and make its application mainstream. Ultimately, smart contracts on blockchains will become disruptive drivers that will usher in a new age in our society.
So now, can you imagine a world where transactions are executed without trust?