A Beginner’s Guide to Understanding the Blockchain (Part 3: Smart Contracts)
Now that you should have a better idea of blockchain’s key characteristics, and how blockchains work (if you don’t, please read through Part 1 and Part 2 of my guide to blockchains), I will go more in-depth into certain concepts that you will frequently encounter in your blockchain/crypto journey.
If you recall from my previous discussions of blockchain technology, I have mainly used Bitcoin as an analogy to elucidate certain properties and structures of a blockchain.
Because of this, you may have the idea that blockchains are solely used to keep a record of cryptocurrency transactions between individuals on a decentralized and distributed ledger that is immutable and fully transparent.
Whilst the decentralized, immutable and fully transparent features of blockchains might hold up in most instances, in some others (private or permissioned blockchains, of which I will discuss in Part 4) they do not.
Similarly, whilst the focus on transactions between individuals also stands true in many cases, in many others — they do not. There are many blockchains that allow for users to interact with another entity entirely: smart contracts.
In other words, not only can blockchains verify transactions in a trustless environment, they can also execute smart contracts.
What are Contracts?
In order to understand what smart contracts are, we first have to start from the very beginning — with traditional, conventional contracts.
I am very sure that all of you are very familiar with the term ‘contracts’, which comes to mean ‘written or spoken agreements that are intended to be enforced by legal means’.
In the real world, we deal with contracts all the time. When we want to buy a car, we have to sign a contract. When we want to rent or buy a house, a contract must be signed. When we sign up for employment, another contract must be signed.
The terms and conditions stipulated in these contracts are usually drawn up by one party, then read, verified and agreed upon by another. These terms and conditions are then expected to be adhered to for one or both parties. If anyone breaks a rule in the contract, the other party can seek to punish via a legal channel, and by engaging an intermediary to enforce the law on the offender.
In order to uphold these contracts, a large amount of resources (paperwork, money to hire a legal representative, human resource as intermediary) would be required. It can end up being an extremely time and money-intensive process.
Moreover, how can we be sure to know when the contract is broken? Sometimes there is no way of finding out until it is too late.
Here, we see two main issues with traditional contracts:
- Time and resource-intensive
- Impossible for anyone to properly verify if contracts are upheld
This is where smart contracts come in.
What are Smart Contracts?
In simple terms, smart contracts are programs stored on a blockchain that self-execute when certain pre-decided conditions are met.
If you recall, in the Bitcoin blockchain, all the nodes on the network will verify incoming transactions before posting any updates to the ledger (only the node that is fastest to solve the computationally difficult proof-of-work problem will get to post that update).
Similarly, on a blockchain that supports smart contracts, all the nodes in the network will execute the actions stipulated within a smart contract once the predetermined conditions are met. These actions could include releasing funds to the appropriate parties, registering a house, sending notifications, or purchasing a ticket etc. — all of which can be classified as transactions.
The blockchain is then updated when these transactions are completed (once again, only the node that is fastest to solve the computationally difficult proof-of-work problem will get to post this update). From this point on, the transactions can no longer be changed (immutable), and all relevant parties will also be able to see the transaction records for themselves (fully transparent).
Smart contracts are typically used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary’s involvement or time loss. They can also automate a workflow, triggering the next action when conditions are met to ensure efficiency.
Let’s see how all these play out in a real-world scenario.
Imagine that John wants to sell a house to Rachel, but is unsure if Rachel will pay him. He can set up a smart contract with Rachel on a blockchain that supports smart contracts (for example, Ethereum), laying out some terms and conditions that ensure he will always get paid.
For example, John can create a clause in the smart contract by writing some simple code, stipulating that the land deed of the house, that signifies ownership, will only be released to Rachel after she has paid him through the blockchain.
This also benefits Rachel, who will feel safe to pay John the money too, because these actions stipulated in a smart contract cannot be changed or reversed once agreed upon (meaning once Rachel pays, the house deed will 100% be released to her).
Benefits of Smart Contracts
From this little scenario, we can see how Smart Contracts bring a lot more extra value over Traditional ones.
- Time: It saves a lot of time for the parties involved because it cuts out the need for intermediaries (middle men/women) and paperwork. These usually will take up a lot of time to negotiate and coordinate with, and fill in, respectively.
- Costs: In the same vein, costs are drastically reduced too due to these intermediaries and paperwork being cut out.
- Efficient: Since they are written as code, these contracts execute almost instantaneously once conditions are met, without the kind of delays that are bound to take place in the case of a traditional contract, and when humans are involved instead.
- Accurate: Because of how these contracts are executed by code and algorithms instead of humans (that can potentially make errors), this ensures that agreements will be carried out to a tee, and without errors.
- Binding: It ensures that no one can default on the agreement, because once agreed upon, the code algorithm will execute no matter what the moment the pre-decided conditions are met.
- Transparent: Because the record of the transaction (after the execution of a smart contract) will be posted to the blockchain ledger for all relevant parties to see, there is full transparency in the whole process.
- Secure: As all transactions that occur on the blockchain are cryptographically encrypted, they are very difficult to hack or track. Moreover, the fact that the blockchain ledgers are distributed across so many different nodes render it almost impossible for records to be changed.
Smart Contract Use-cases
As should be obvious to you by now, smart contracts can be very useful in many different situations.
Here is a concise infographic (non-exhaustive) that lists out such situations:
If you can think of more use-cases, feel free to start a discussion down below!