Smart contracts are being widely discussed and there are ICOs taking place every week around the world to help fund their development.
One of the primary applications of blockchain is smart contracts that implement the features of blockchains in accomplishing tasks that otherwise require the involvement of a third party, or/and requires storing data on a centralized server that is prone to hacking.
This is a basic guide to help you understand why smart contracts are being so widely discussed, how it mitigates the shortcomings of the existing models, include what they are, how they work and where they are being widely used.
Understanding Contract Law and Ownership – Prequel to Understanding Smart Contracts
Before diving into smart contracts, I will explain why smart contract is a buzz word today and why every one is talking about them.
Our society thrives on agreement. Agreement is nice.
If you think for a moment, you will find that there is agreement of some form or the other existing everywhere.
Agreements can be of varying degrees and consequences. Certain agreements hold little consequence to the society, while agreement on other things can be more significant to the society.
Here are a couple of examples.
Which is the best IPL team?
For me it is Kolkata Knight Riders, for you it might be Royal Challengers Bangalore or Chennai Super Kings or some other teams.
Agreeing or not agreeing to which is the best team is of little significance to the society. If you do not agree with me, we may debate on it based on facts, there might be hard feelings.
But to the society, it does not matter much.
Now consider this.
Which language should the region use to communicate? Or what form of currency should be used?
These are questions that requires broader consensus, without which the society would not function as desired. And that is the reason why society has a set of rules, also known as laws.
One of these laws can also be about entering into agreements with citizens of the society. It would specify what agreements members of the society can enter into, and what to do if one of the participants does not hold up their end of the contract.
This agreement about agreements is known as agreement law.
Ownership in Society
Another important thing a society needs to agree upon is whether members of the society can own things.
Once this is taken care of, there needs to be agreement on who owns what.
Ownership of certain things are of little importance – like owning a pair of shoes, or owning the latest iPhone. Losing any of these would make you sad but would not shatter your world
However, losing your apartment or house would be a life changing event. If it was easy to steal houses, thieves would steal them because of bigger money. And owners of the house would spend their time, energy and money protecting them.
This is exactly the reason why there needs to be agreement of ownership in the society.
So how does the society have agreement on ownership of residential places like houses and apartments? We have government agencies that maintains, updates and enforces a registry of who owns which house.
Similarly, central agencies have vehicle registers to keep a track of vehicles, banks to track finance of individuals, and so on.
In short, the most important point to note here is that there ownership agreements are centralized.
Ownership and Centralized Network
Let us go back to ownership once again. And consider ownership of money.
Ownership of money is maintained by the bank (considering every single piece of currency is maintained by the bank). Bank maintains a list of all the account holders and their balances.
So whenever you have to send some amount to your friend, you would request the bank to do it. The bank would update the list by deducting the amount from your balance and adding the same to your friend’s account balance.
In a way the bank is updating the agreement of ownership of money, thus being the central authority to maintain the account balance.
One fine day, members of the society decide that they would not want the bank to be the sole authority of maintaining this ownership. Instead, members of the society would maintain it.
Each member of the society would have a list of account details and account balance, similar to the one that the bank maintained all this while.
Whenever a transaction would happen, every member would update their copy – because there has to be agreement on uniformity in account balances. To do this they can meet and update their copy.
For certain change in ownership this would work – like if the change in ownership happen once in a decade.
However for our example, this would not work. If all the members need to meet in order to update the list every time a change in ownership of money (or transaction) happened, it would be a good example of inefficiency and the society would be dysfunctional soon.
Blockchain to the Rescue – Ownership, agreements and smart contracts
That’s where blockchains come in.
To spare all the jargon, consider blockchain to be based on magic.
A typical public blockchain can do the following:
- Agreement is maintained on a set of documents
- Anyone can participate in maintaining the agreement
- Changes allowed in the agreement are governed by rules
- Valid changes are automatically updated with all the documents with others
This system ensures that all participants have the same copy. There is no central authority. In a way this is a decentralized and tamper proof system. Theoretically.
Every blockchain system needs to have its own form of currency. This currency is used to pay the participants who work hard to ensure that the agreement is never broken and the system remains up, functional and secure.
Bitcoin is a currency. You can’t just have bitcoins. You have to buy them – using forms of currency that are considered legal in the society. This can be Rupee (in India) or dollars (in USA) or the pound (in UK), and so on.
Whenever you send a bitcoin, it does not get physically transferred to the other account. Instead, the ownership gets changed. Or in a more specific way, the distributed agreement about the ownership of the bitcoin is updated.
This very property can be used to maintain the ownership of physical assets as well – gold, real estate, website ownership, arts and paintings.
The more experts thought about ways blockchain can be used in daily life, there came a need to not just apply blockchain to function according to the agreement coded in it, but to instead enable any one using the platform to make agreements about how to update the agreements by following some basic rules.
These agreements about how to update the blockchain agreement is what we call as smart contracts.
Smart Contracts – Motivation
Before I go ahead and define what a smart contract is and dive into how it works, let me give you an example.
You want to send a truckload of goods to Rajeev in another city. The person delivering the goods is the truck driver named Ravi.
Now you do not trust Ravi with the goods. But you trust your friend Rajeev. Also, Ravi does not trust you with the payment.
To ensure that the goods are delivered and the payment for the delivery is made, there is a contract made.
A third party is involved who puts down the terms and conditions, and other necessary details to which both you and Ravi (?(the trucker) agree to.
However, this contract is mostly on paper and there is a chance of tampering. Also one of the parties may still choose to break the terms and conditions in the contract and cause loss to the other.
Can’t we simplify the process and make it tamper proof. That’s where smart contracts come in.
Now imagine a computerized contract where all these rules, terms and conditions are programmed into the system through code.
As per rules in the system, you make payment to the smart contract when the goods are loaded on the truck.
But the payment will not be made to trucker Ravi. Once Ravi has made the delivery and Rajeev has confirmed the same, the payment will be released to his cryptocurrency wallet.
But since we are talking of smart contracts here, why would I need Rajiv to confirm the delivery.
Instead we can have GPS tracking in place to ensure whether the delivery has been made at the correct coordinates. If the location rule is made, the payment is released.
You may point out that the code can be tampered with. No, that is the beauty of blockchain based systems. The code would reside on every system or computer that decides to participate in the process.
What is a Smart Contract?
Smart contracts are automated computer programs built over the blockchain where the agreements are programmed with the ability to facilitate, execute, enforce and perform on its own with the sole aim of enabling two anonymous parties to trade and do business with each other over the internet without the need of a middleman.
These are also known as self-executing contracts, blockchain contracts and digital contracts.
In simpler words, a smart contract consists of logic in the form of computer code that is stored and executed on the blockchain network.
Smart Contracts Blockchain Explained – Traditional Contracts vs Smart Contracts
In a traditional contract, legal professionals prepare and document the rules, guidelines, penalties in hundreds and thousands of pages of documents and for enforcement depend on third parties.
This enforcement is also time consuming and parties need to resort to public judicial system in case things do not go as expected (one party breaks the contract). This also increases costs.
In a smart contract, all these rules, regulations, terms, conditions are programmed into the system. They are present in the form of code and can execute themselves based on the event occurred.
So if you have noticed, in a smart contract you are not dependent on a third party for enforcement which drastically cuts down waiting time and costs.
Smart contracts does not just define the rules and penalties around a contract or agreement. It also automatically enforces these obligations.
The system works on the If-Then premise and you can expect a faultless delivery of expected results because it is decentralized.
You can use smart contracts for all sort of situations that range from financial derivatives to insurance premiums, breach contracts, property law, credit enforcement, financial services, legal processes and crowdfunding agreements.
You can consider a vending machine to understand how a smart contract works on the basis of conditions coded in them.
In a vending machine you would put in your money and the vending machine would automatically release the chocolate or cola can in the tray for you.
Smart contracts enable control of ownership of real assets digitally.
How do Smart Contracts Work?
On a blockchain, the working of a smart contract can be divided into three phases, as explained below:
1. What Goes in a Smart Contract – Code
Since the rules of the contract will be present in the form of the code, it is very important for the code to do exactly what the parties want them to do.
This is done by properly implementing the logic through code, and most of it is done on Ethereum through the programming language called Solidity.
As I have already mentioned, the premise of code is mostly “If…this…then…this…else…this”.
2. How is the Smart Contract Sent Out – Distributed network (Blockchain)
Once the smart contract is developed, it is encrypted and deployed on the blockchain. The decentralized nature of the blockchain network ensures that the smart contract is sent to all the computers on the network.
Any changes made to the code is sent to all the computers in the network to ensure stability and one state of the ecosystem.
3. How it is Processed and Executed
When the computers receive the smart contract code, each of these computers come to an individual agreement on the results of the code execution.
The network in turn would monitor for compliance as per the logic coded in the smart contract.
The automation ensures that whenever a specific event is triggered or a specific date comes, the system triggers the obligation.
I have covered specific examples from the industry later in this article as use cases.
Why Smart Contracts – What are the Benefits and Features of a Smart Contract
The reasons to consider smart contracts are many. In this section, I have discussed some of the benefits.
Parties involved in the transaction process are always informed by the network of what is happening and when it is happening. This leads to increased accountability.
The need of a third party like broker or lawyer goes away. Since execution of contract happens over a decentralized network, there is no danger like manipulation by a single individual or possibility of human error.
The execution is automated and happens based on triggers which can be based on an event or a date, for example.
Smart contracts are error free (unless there is a bug in the code) because manual intervention to document, review, monitor and process does not exist. It is replaced by code.
Since smart contracts are operated over blockchain, there is no chance that your record will get lost. Every computer participating in the consensus process will have a copy of the record. You are backed up against any data loss.
Smart contracts reduce turn around time. In traditional method, a lot of time is required for paperwork, revision and processing of the documents. However, smart contract code automates the tasks saving time.
Safety and Security
Because of the nature of the network, the documents are safe and encrypted using cryptography. Hashing algorithms (like SHA 256) are used to ensure that documents are encrypted ensuring top notch security.
Also the data is stored across the network in every computer that is participating in the process.
Smart contracts save you money since they remove the need for a third party. Be it a broker or a lawyer or a notary to witness the transaction, smart contract requires none of these leading to cost savings.
Smart contract transactions are transparent. Any individual on the network can go back and check the transactions for verification. This ensures transparency.
Of course, every transaction that ever occured exists and there is no way for some one to delete a record from a block because of the nature of the network.
Your assets on the blockchain will never be lost. They remain on the network in encrypted form.
Smart Contracts v/s Traditional Software
Smart contracts have unique characteristics compared to other types of software:
Firstly, the program is itself recorded on the blockchain.
Secondly, the program can itself control the blockchain assets, store and transact value.
Thirdly, a smart contract program is executed by the blockchain.
Smart Contracts Types
Smart contracts can be largely classified into the following four types based on their application:
Smart Legal Contracts
Smart contracts that use code to articular, verify and enforce agreement between parties are called smart legal contracts.
These would be a combination of code and traditional legal language. For example, imagine a smart contract with car dealer. The payment terms can be coded in the smart contract and executed automatically when the delivery happens.
The dealer can however insist that the contract includes an indemnity clause. (According to Wikipedia, an indemnity is an obligation by a person (indemnitor) to provide compensation for a particular loss suffered by another person).
Since this clause cannot self execute, there is no need to maintain that in the smart contract code.
Decentralized Autonomous Organizations (DAOs)
DAOs are organizations that run in the blockchain and is autonomous in nature. There is no presence or existence of centralized leadership as is the case with all organizations that exist today.
Organizations that run on the blockchain using smart contracts have a set of rules by which the members (who share a common interest) participate in decision making and transactions over the network.
New projects are approved and executed based on consensus mechanisms that are an inherent feature of blockchains.
Decentralized Applications (dApps)
Decentralized applications is a type of smart contract where an application is executed over the blockchain.
A normal application that runs over the internet stores user data on a centralized server that is prone to hacking and manipulation.
dApps do the same job but because it happens over the distributed and decentralized network, it is more secure. It also provides a possibility where users who actually participate in the process are provided incentives which is not the case today.
For example, Facebook earns a lot of revenues by collecting user data and using them to drive ads on its network. Now if Facebook were to be a dApp, it would distribute a part of its revenue to users for using its platform.
Smart Contracting Devices
Current IoT ecosystems rely on centralized, brokered communication models, otherwise known as the server/client paradigm. This leads to increased costs, makes them insecure.
Smart Contracting Devices are basically devices that are internet enabled and run over the blockchain network. The above demerits are taken care of, all thanks to smart contracts.
The following are all protocols or platforms which can be used to create smart contracts:
Smart Contract Examples and Applications
Smart contracts find applications in many areas. Some of them are:
- Improving governance
- Supply chain
- Credit Enforcement
- Real Estate
- Breach Prevention
- Property Law
- Finance Services, etc.
You may also read a detailed post that I have on smart contract examples and blockchain applications.
The Final Words
Smart contracts have the potential to define how our future will be.
Smart Contracts are not perfect today. There is always a high probability of a bug existing in the code (similar to how they exist in software and web applications).
The technology will enter our everyday life and every effort is being made by researchers to ensure seamless delivery of the technology among the masses.
The list of challenges are pretty long and as a blockchain enthusiast, I can only hope that they get ironed out.
Let me end with what Gavin Wood, CTO, Ethereum has to say –
“The potential for [smart contracts] to alter aspects of society is of significant magnitude. This is something that would provide a technical basis for all sorts of social changes, and I find that exciting.