One of the key technology innovations of second-generation blockchains has been the development of what are called smart contracts. Smart contracts are computer code that is stored inside of a blockchain that encodes contractual agreements. Smart contracts are self-executing with the terms of the agreement or operation directly written into lines of code stored and executed on the blockchain computer.
In the traditional sense, a contract is a binding agreement between two or more parties to do or not do something. Each party must trust the other parties to fulfill their side of the obligation. They are a written or spoken agreement that is intended to be enforced by law. A multiplicity of different contractual agreements form the institutional foundations of our modern society and economy, which have evolved since ancient times. If we think about something as seemingly simple as a cafe serving a cup of coffee, we will see that this process is really enabled by a massive amount of contractual agreements between different parties that enable them to cooperate in delivering that outcome. Contracts between employees and employer of the coffee shop, contracts that provide workers with health coverage, contracts that ensure the coffee-shop, contracts between suppliers along the supply chain, contracts between the property owner and tenant, etc. Our economies are powered by a massively complex set of contractual agreements that are currently created and enforced by centralized organizations like insurance companies and banks, which themselves are supported by the ultimate centralized authority in the system, the institutions of the nation-state. Our societies and economies are almost completely dependent upon third-party organizations to maintain and enforce those contractual agreements.
Smart contracts feature this same kind of agreement to act or not act, but they remove the need for the trusted third party between members involved in the contracts. This is because a smart contract is defined by the computer code and executed or enforced by the code itself, automatically, without discretion. Through smart contract technology, blockchains can remove centralized systems and enable people to create their own contractual agreements that the computer code can automatically enforce and execute. These smart contracts are decentralized in that they do not subsist on a single centralized server but are distributed and self-executing across a network of nodes. This means that untrusted parties can transact with each other in a much more fluid fashion without depending upon third parties to initiate and maintain the rules of the transaction.
Likewise, smart contracts enable autonomy between members, meaning that a contract and its initiating agents need not be in further contact after it is launched and running. An illustration of this concept is a vending machine. Unlike a person, a vending machine operates algorithmically. You provide the source input of money and product selection that the machine takes as input and automatically executes a rule to produce the pre-specified output. The same instruction set will be followed every time in every case; when you deposit money and make a selection, the item is released. There is no possibility of the machine not wanting to or not feeling like complying with the contract, or only partially complying, as long as it’s functional.
Here’s another example. We can think about a situation where four people pool their money to make a joint investment that will return their interest. A smart contract could be programmed on the blockchain to take any interest created, divide it into four, and send each amount to the corresponding wallets of the different stakeholders. A smart contract is really just an account on the blockchain controlled by code instead of by the user. Because it’s on the blockchain, it is immutable, which means the code cannot be changed, and thus all participants in this investment can be assured that they will get their fair share automatically. The code dictates how the process will take place, and no individual has the power to change it— no individual, no organization, or no government can censor, alter or manipulate the contracts. In this respect, it’s often said that code is law, in the sense that the code will execute, no matter what.
Of course, computer code has been for a while now, acting as the law. For example, as services have gone online, we are increasingly faced with web forms that strictly control what inputs are allowed. If you want to buy an item on iTunes in the USA, then you’ll have to have a credit card with a US address. The system will also enforce this by not letting you complete the purchase with an incorrect address. As another example, a logistics company could use smart contracts to execute code that says, “if I receive cash on delivery at this location then trigger a supplier request to stock a new item,” since the existing item was just delivered.
A combination of smart contracts with blockchain encoded property gives us the notion of smart property. Smart property is simply property whose ownership is controlled via blockchain encoded contractual agreements. For example, a pre-established smart contract could automatically transfer the ownership of a vehicle title from the holding company to the individual owner when all the loan installments have been cleared. The key idea of smart property is controlling ownership and access to an asset by having it registered as a digital asset on the ledger and connecting that to a smart contract. In some cases, physical world hard assets could quite literally be controlled via the blockchain.
One example of such an IoT blockchain system is Slock. A door lock connected to a smart contract on the blockchain controls when and who can open the lock. This enables anyone to rent, sell or share their property without the need of a middleman. With such innovations, parking spots can be sublet on-demand, Airbnb accommodation could become fully automated, or someone with twenty bikes in Bangladesh could rent them out. The bike could shut itself off with smart contract locks if it has not been paid for or stolen. Likewise, there could be an automatic deposit system, and if the person wanted, they could pay a certain price to purchase the bike at any time.
Like all algorithms, smart contracts require input values and only act if certain predefined conditions are met. When a particular value is reached, the smart contract changes its state and executes the programmatically predefined algorithms, automatically triggering an event on the blockchain. Overall, the workings of contracts can only be as good as the data that is input. If false data is input into the system, then it will output false results.
Blockchains cannot access data outside of their network, requiring trusted data feed as input to the system, such as an Oracle. An oracle is a data feed provided by an external service and designed for smart contracts on the blockchain. Oracles provide external data and trigger smart contract executions when predefined conditions are met. Such conditions could be any data like weather temperature, the number of items in stock, the completion of a successful payment, changes in the prices on the stock market, etc. In the context of blockchains and smart contracts, Oracles are an agent that finds and verifies real-world occurrences and provides this information to a blockchain to be used by smart contracts. An oracle is a third-party service, which is not part of the blockchain consensus mechanism; thus, whether it be a news feed, website, or a sensor, the source of information needs to be trustworthy.
For example, we could think of an online betting platform based on the blockchain that uses smart contracts to automatically execute payouts to people who have placed bets on sports matches. The smart contract system would then have to be connected to a trusted oracle to provide it with the score of the matches. As of present, this Oracle would likely have to be associated with some trusted third-party centralized organization, like a sports channel or Bloomberg for stock prices. However, in the future, through datafication and IOT pervasive sensing, this might also be automated given the use of advanced analytics using automated oracles that draw data from a myriad of sources and complex analytics, to find cross-correlations that provide a statistical assurance that, for example, a given event occurred or did not occur.
The advantages of smart contracts are numerous:
- They are automatic, which could remove the time and costs associated with managing and enforcing them making, them more efficient as they can be cheaper and faster to run. Through this form of automation, a much greater amount of exchange could take place that otherwise would have never happened. In such a way, we can see how distributive ledgers and smart contracts are a key part in enabling a true services economy where ownership is displaced by temporal usage through the on-demand provisioning of services.
- They could reduce corruption, as code is both transparent in its workings and automatically executed. This leaves room for individuals or organizations to alter it to their advantage.
- They can reduce dependency upon centralized organizations. So, people may set up their own contractual agreements, peer-to-peer, thus limiting the arbitrary power of centralized organizations.
- They can also deliver certainty, as smart contracts guarantee a very specific set of outcomes that are predetermined beforehand, enabling all parties to know exactly what will happen.
But, herein also lies some of their limitations. By automating the execution of a contract, they are dependent upon formal rules with well-specified inputs and leave little room for a multiplicity of eventualities, where the rules may need to be slightly altered because of unforeseen circumstances. For example, a car being used on-demand that operates through a smart contract may shut the user out if they have not paid their bill and take little accounts that it may be a life-or-death emergency usage. Many unpredictable and unforeseen events occur in the real world, and rules sometimes need to be flexible and adaptable to accommodate. This is one advantage of having human oversight as people are much more capable of judging such circumstances and responding appropriately to complex, unforeseen eventualities. So, the degree to which we can automate contracts is relative to the environment operated in. In more complex situations, there will often need to be some form of governing body to intervene when needed, and this creates new complications surrounding governance that are still yet to be figured out.