A Beginner’s Guide to Smart Contracts
Latest posts by Dean (see all)
- DBX – The Blockchain For Real World Apps Launches Official ICO - September 25, 2018
- Here’s why you should be excited about ‘blockchain phones’ - September 24, 2018
- Bitcoin price fundamentals: bullish divergences may be pointing towards price increase - September 8, 2018
What is a ‘Smart Contract’
To put it as simply as possible, the term ‘smart contract’ can refer to any contract which is capable of executing or enforcing itself.
Smart contracts are written as programming code rather which can be run on a computer rather than in legal language on a printed document. This code can define strict rules and consequences in the same way that a traditional legal document would, stating the obligations, benefits and penalties which may be due to either party in various different circumstances. But unlike a traditional contract it can also take information as an input, process that information through the rules set out in the contract, and take any actions required of it as a result.
What’s The Point in Smart Contracts?
The main purpose of designing smart contracts is to enable people to trade and do business with strangers, usually over the internet, without the need for a large centralized authority site to act as a middleman.
This is important because the main problem with shopping online, hiring people over the internet, and generally conducting business with strangers over the internet is the issue of trust. Most business requires some element of trust. For example, if I buy something at an online shop I am trusting that they will send it to me after I make a payment, and if they do send it to me they are trusting me not to reverse my credit card payment to take both the money and take the product for free. Up until now scenarios such as this have been solved by both parties going through large well-known sites which they both trust. For example, one of the great benefits of the internet is that it enables ordinary people to easily buy and sell things between each other – but the only way we have found to solve the problem of trust is for the vast majority of this p2p trade across the whole western world to go through a single gigantic virtual-monopoly website called eBay. Not only do these giant middleman sites charge significant fees for their service, they also impose their own limits and controls on what and how people trade, therefore severely limiting our business freedom.
By solving the problem of trust without the need for middlemen smart contracts can reduce business costs, reduce consumer prices, and increase our freedom to conduct our own business in whatever way we ourselves see fit.
Types & Examples of Smart Contract
- Breach Prevention: An early and fairly simple example of a smart contract is Digital Rights Management or DRM technologies. This type of contract does not take or process inputs, but simply enforces itself by making it impossible for you to break the contract by acting in an unauthorised manner – for example by copying music or video file which is protected by copyright.
- Property Law: Cryptocurrencies such as Bitcoin can be thought of as a set of smart contracts which enforce property law. Cryptographic techniques are used to ensure that only the owner of a digital token such as a bitcoin can spend it. Several decentralized asset exchanges already exist, which broaden out the range of asset so that many different digital assets can be traded on a single block chain. The same principle can also be extended to physical products with electronic controls or embedded microchips.
- Financial Services: Cryptocurrency obviously opens up a wide range of different use case for smart contracts which wouldn’t otherwise be possible. For example, systems such as the one used by BurstCoin are able to run auctions which automatically check for the highest bidder within a set time limit and refund everyone else, automatically transfer dormant funds, or run a decentralized lottery. This kind of smart contract only takes very simple numerical values as inputs, performs purely mathematical evaluations, and outputs a financial transaction through a cryptocurrency protocol. Another example would be Bitshares’ pegged assets, the creation of which by traders requires collateral to be put into a contract which has the power to sell that collateral if the market moves against its owner.
- Credit Enforcement An extension of property law, and a classic example of how smart contracts can be used in the real world, is credit agreements which disable your product if you fail to make your repayments. For example, you might imaging a future in which you buy a new car on credit, you fail to make the repayments, and your car simpy locks its doors and drives itself back to the showroom. Most electric products could be fitted with a ‘kill switch’ which disabled them if a simple condition is not met – such as a payment being made through a public channel such as a cryptocurrency blockchain.
- Oracle contracts: The main limitations to what can be done with smart contracts is that a computer program cannot easily and reliably tell what is happening in the physical world or who is telling the truth. Checking whether a bitcoin payment has been made is a simple task which is suitable for a computer program to do, but most real-world contracts and situations (for example: was a product really delivered to someone? Did a freelancer deliver work that met the company’s stated requirements?) are much harder for a computer program to evaluate. A smart contract’s execution is only as good as the inputs it takes in, and it may be difficult to find inputs which are sufficient to the job which both parties trust. One solution to this is to have oracles – online services providers whose job is to broadcast data which can be used as inputs by smart contract makers. For example, an oracle may broadcast new entires on the government registry of deaths, to be used by contracts executing wills, or the results of a football match, to be used in settling gambling bets. This method is used by Ripple’s Codius smart contracting platform
- Double Deposit Method: Some of the first working examples of smart contracts in the realm of cryptocurrency used the double deposit method pioneered by BitHalo and BlackHalo. This deceptively simple, but still very powerful method, is ideally suited to use with cryptocurrency. When entering into a contract such as this each person is required to make a cryptocurrency deposit into the contract’s program. This program has a set time before it expires. If the people involved in the contract cannot come to an agreement over how to proceed before the contract expire the funds are ‘burned’ – which means sending them to an address which nobody knows the private key for, effectively making them unspendable. The program itself doesn’t, therefore, make any attempt to decide whether each party has lived up to their obligations or who should do what to fulfill the terms they agreed to. But what it does do is to make it impossible for anybody to make a profit by cheating the other person – by ensuring that by breaking the contract they stand to lose exactly as much as they could gain. It also pushes all parties to put maximum effort into dispute resolution to comes to an agreement everyone can accept before the timer runs down and their funds are burned.
Smart Contract Platforms
The following are all protocols or platforms which can be used to create smart contracts.