Smart contracts are a prime example of a technology created ahead of its time. While many in the blockchain space associate them purely with cryptocurrencies, the fact is that they actually existed long before the blockchain did. Believe it or not this technology was first conceptualized way back in 1994 by Nick Szabo, who coined the term. However, it would be many years later before smart contracts would be anything more than a mere concept.
While Szabo himself is a bit of legend in the world of cryptography and cryptocurrency, smart contracts honestly do not apply only to the blockchain. They are simply a tool which can be utilized by it and the many projects that have been created within the space. In this article we’re going to explore those applications and learn a little bit about smart contracts, but first let’s talk about why you would want to use a smart contract to start with.
A trustless society.
Contracts exist for many different relationships in the world of business or personal relations. In some cases these contracts may be of a verbal nature where two or more parties agree to a certain set of rules without a formal agreement. In other cases these contracts may need to be a little more iron clad, requiring lawyers and well planned out paperwork to protect all those who are involved. Obviously, the more money that is at stake the more protections a business or individual will need in order to be sure that the terms of these agreements are met.
It’s easy enough to create a contract with another party, but it’s not always so easy to get them to honor it. Currently, if two parties can’t come to an agreement on their responsibilities or one party refuses to uphold their end of the deal then the authorities will intervene. In some cases these issues may be brought to court and a judge will need to provide a ruling as an impartial third party. This is not ideal for either side as it is often very expensive and time consuming to pursue these claims. This also means that in many cases these parties may be forced to just accept the loss if the proceeds would need be greater than the cost to fight for what is rightfully theirs in a court of law.
What if instead there was a trustless method by which people could create contracts with each other? A system such as this would allow anyone in the world to conduct business with anyone else without the need of a complicated legal system. They could instead manage these relationships themselves using a computerized contract which could automatically ensure that both parties fulfilled their respective obligation.
Smart Contracts as a concept.
A smart contract by definition is a computerized transaction protocol set to execute on terms set by the parties who have created it. In most cases these are financial, and common examples of the types of obligations that smart contracts could fulfill include loans or payment terms. However, the application of this technology could actually be quite wide, and in the future we could see these contracts applied to more complex markets such as insurance where numerous conditions could impact the payout from the contract. A smart contract’s ultimate purpose is to reduce the risks of fraud and the costs associated with the enforcement of business agreements through automation and intelligent computer software.
In his paper on the subject, Szabo cited a simple device as an example of the work that a smart contract does, the vending machine. As a primitive example, the vending machine accomplishes the same goal. The consumer agrees to pay a certain amount of money for product within the machine. The mechanism within the device then dispenses the appropriate product and even change as agreed upon. The machine’s owner enjoys reduced labor costs thanks to this automation, and the consumer enjoys a greater convenience. Smart contracts are a much more intelligent vending machine, capable of dispensing the rights to products or financial incentives to participants in a way that greatly reduces the risk of fraud.
How do smart contracts work?
The basis of every smart contract starts with an equation. You may be familiar with conditional statements which are common in scripting languages such as PHP. These scripts function based on the triggering of certain conditions. For example, you could create a statement like this if you need to specify conditions for a certain subset of visitors.
If the visitor is from the United States
Then display this information.
Else display this information instead.
In this case, if the condition is met, then the user will be shown information that is specific to users in that location. If the user is not from the United States then they will be shown something else. Depending on what you wanted to show your users this could lead to a series of events for each country or just a default message if they are not located in the location for which you have implemented the trigger condition.
This is a simple example of how a smart contract works. The application is very much the same in both cases, except with different goals. In some cases the contract will be as simple as this one, but in other situations the contract may require more extensive coding, even include multiple conditions which must be met in order for the contract to be executed.
This transforms an otherwise basic premise into something with a wide array of applications. It’s theoretically possible that you could create a smart contract which could be triggered on any condition. This opens up the possibility of using them to literally any business no matter what industry it’s in.
Smart contracts as used in blockchain projects.
The idea of smart contracts was conceptualized long before cryptocurrencies were born, and they do have the ability to be used without them, but the blockchain really gave wings to this technology. Since becoming associated with the blockchain, the adoption of smart contracts has been embraced by individuals all over the world. Ethereum is of course what everyone thinks of when smart contracts are mentioned, and the Ethereum foundation’s work is what brought smart contracts from obscurity to a massive phenomenon. However, there are plenty of other interesting projects that are utilizing smart contracts in their own ways to create solutions for everyday problems. Here’s a few of the more interesting solutions that are currently in development.
Augur is a blockchain project that revolves around something called prediction markets. A prediction market essentially turns any event into a tradable token. This means that interested parties can place bets against anything from sporting events to the outcome of political elections, creating a unique opportunity for investors to place educated bets against the outcome of situations which they are familiar with. There’s no need to have an advanced knowledge of certain investment vehicles or markets to participate in the Augur ecosystem. Instead you can simply use the knowledge you already have to your advantage by creating your own prediction market based on events and industries which you already understand.
The way Augur works is that each event becomes its own tradable token. These tokens are exchanged within the platform leading up to the event in question. The system uses smart contracts to facilitate the management of these markets. Once an event has occurred and a result has been tallied, the contract activates, and it automatically pays out what is owed to the participants in the market surrounding that particular event. This allows Augur to function as a decentralized system that doesn’t require outside authorities to manage any payments, and their users do not need to trust any third parties with their funds.
Oyster is working to solve two very large problems that the web currently faces. While these issues do not immediately seem to be connected, the team melds them together in a way that they can complement each other nicely. The first issue involves the storage of data on the web. Currently, much of the world’s cloud computing is controlled by only a few major companies. This is a huge problem, because it means that if one of these providers goes down it could actually negatively impact a large chunk of the internet. Some of these providers are also not very upfront about how they manage their customer’s data and what other parties they are sharing this data with. Users of the Oyster platform will have access to a decentralized and anonymous storage platform which they can pay to use. This gives users the ability to not only control their data, but it also prevents information from being censored or restricted.
The second part of their solution addresses the issue of monetization for publishers. Revenue from website is falling, and many publishers are struggling to earn a reasonable income from their websites despite growing traffic. Many visitors are also frustrated with intrusive ads and data harvesting that ruins their browsing experience and threatens to destroy their privacy. To that end, Oyster has created what they believe is an alternative method.
By utilizing an interesting approach to proof of work mining, publishers in the Oyster system can earn cryptocurrency thanks to the many visitors who are browsing their websites. Instead of using their own machines to access hash power for mining, they use the computing power of their visitors instead. Remember when we talked about data storage earlier? Well, when users pay out the tokens required for their data hosting, half of that money is actually dumped into a smart contract. Once a visitor lands on a website, their device begins a sort of treasure hunt, and if they are successful, then the smart contract in question will automatically pay out its contents to the website owner’s Ethereum address.
Traditionally lending has been controlled only by banks. This is not really because there is any kind of legislation preventing people from loaning money to each other in most locales, but simply because it’s difficult to do so safely. However, thanks to the blockchain, we could soon have more options than just using traditional lenders. This is good news for many people who may actually be good candidates for loans but have limited credit history. It could also help people who need smaller loans to progress their small business, as most banks won’t even issue a loan for less than $5,000.
Elixir is a decentralized blockchain application that allows for individuals to issue trustless loans to one another thanks to smart contracts. The platform sets no rules for what can be used in these contracts and users are free to set whatever terms they wish for their loans as long as both parties agree. These contracts can even hold collateral which will automatically be returned after repayment or even awarded to the lender if a loan is defaulted on. Using collateral is optional, but it is a great way to make sure that lenders have little to no risk of default, and smart contracts do an excellent job of facilitating that without the need of a trusted third party.
Hydrogen’s aim is to revolutionize the way that banks deal with their customers on a day to day basis, and it will all be managed by smart contracts. This platform will allow their financial partners to easily create applications on the blockchain that are more secure and offer them superior features to their existing systems. Developers will also have access to easy to use API which they can easily plug into their banking applications. There’s also the added bonus that these smart contracts can actually be triggered by events that happen off chain and are not limited to things happening within the Hydrogen ecosystem.
For example, if a banking application wants to process a purchase there are many steps that must be taken before it can go through. While the transaction for this purchase is occurring off chain, likely through a merchant’s point of sale system, other things are happening on chain at the same time. These transactions can be linked on chain for processes like fraud prevention, escrow services or other features that could be important to the transaction or provide additional utility for either the vendor or the consumer.
Hydrogen specializes in cutting out much of the work involved with running financial applications. Their software can add extra layers of security, provide more transparency to banking customers, verify the identity of users and even provide verification of vital documents on the blockchain. Developers interested in utilizing their service will be able to tap into any of these softwares using APIs and smart contracts in order to build more secure and more efficient banking applications for their clients.
Want to see some smart contracts in action?
While many blockchain projects are still waiting to be fully developed, there’s actually a good number of applications which are already using smart contracts. If you’re interested in seeing the power of smart contracts in action, then try one of these platforms on for size.
This blockchain game allows users to own and breed their own digital kitties. If there’s anything that the internet loves it’s cats, and denizens of the crypto side of the internet quickly ate this game up. Under the hood, these cats are actually digital collectibles. All of them are unique, and they are managed by smart contracts.
Part of the game involves breeding these cats to produce additional assets for the player, and this is based on of course conditions which revolve around the cat’s unique traits. The offspring generated is random at best, and there are no guarantees, but it’s all part of the smart contract which determines the game.
For many content creators, their work is all that they really own. Unfortunately, not everyone gives these creators the respect that they deserve, and they are constantly fighting plagiarism and content thieves trying to profit off of their work. This presents an interesting opportunity for an immutable ledger which can be used to create a time stamped and permanent record of when a work was created.
Po.et allows publishers to register their work to the blockchain, providing them with verifiable proof that the content in question is their property. These users can then utilize or create smart contracts that give them the control over their work that they desire. This includes the ability to set usage terms that are more customized that blanket usage licenses like creative commons, and it even allows these publishers to collect fees for the usage of their work should they want to allow other publishers to use it on their sites.
This esports platform allows for gamers to play competitively online for prizes. All of which are paid out in cryptocurrency with smart contracts. While online gaming tournaments are nothing new, traditionally users were forced to trust the operator of these events, who was likely an anonymous or unknown party. This of course lead to many unsavory tournament organizers not honoring the terms of their agreements.
Thanks to smart contracts, Firstblood is able to offer their users a trustless ecosystem where prize money is held in a computerized escrow. Tournament participants can verify that the funds are present before the match begins by vetting the contract, and they can be sure that if they are victorious they will actually be paid. This means that gamers are free to participate in events hosted by anyone with no worries about whether the match will be fair or if the match organizer is trustworthy.
What does the future hold for smart contracts?
While the use cases we’ve talked about already are great, it’s likely that there’s still many more amazing things to come for smart contracts. Here’s a few more cool uses for them that we could see pop up in the near future.
The insurance sector relies heavily on data, and the blockchain is likely an excellent place for these companies. In the future it’s possible that insurance policies could be issued via smart contracts, and then they could pay out their benefits based on certain events that may take place in the future or even multiple events. They could also use outside events with this data to change a customer’s rates for better or for worse. For example, they could automatically provide a discount based on how long its been since an accident was reported or conversely, they could raise rates for high risk individuals.
Wills and trusts
Everyone needs to have a will in order to be sure that their assets are distributed to the desired parties upon their death. This functionality could easily be automated to make sure that paperwork is not lost or tampered with. There is actually one blockchain project working on this currently, and they use smart contracts to automatically distribute certain information or even assets to relevant parties. This information could include things that investors may need to provide to loved ones when the time comes, but they would not want it to be given out until their death, such as passwords or private keys. Using a smart contract removes the need for them to trust a third party with this sensitive information.
The management of copyrights is a tedious procedure, but it is vitally important for musicians, authors, photographers and artists. Often times it can be difficult for these creators to make sure they are being paid for their work, and it may even be difficult for them to be able to prove that they are the ones that own the work in question. Smart contracts can not only make it easier to manage these works, but they can even assist in paying the parties involved, even if there are several creators registered to the same work. For example, a smart contract could pay all the members of a band equally for their contribution to a song, and the ledger would provide a transparent record of these payments so artists could verify that they are getting exactly what is owed to them by the record label.
Why would you want to use smart contracts?
There’s a lot of advantages to using smart contracts. Besides the fact that they can enable some pretty cool stuff, there’s also some other underlying benefits that may not be apparent at first.
They provide transparency
Smart contracts are always fully verifiable. That means users can examine the code themselves to make sure that not only is the provider of said code acting in a manner which is appropriate, but it can also be personally vetted for security flaws that could be dangerous to users. Potential flaws will be uncovered by the community and quickly rectified.
They reduce overhead costs
Automation saves many work hours, and there’s no need to involve expensive courts or legal systems, especially in smaller contracts. This gives individuals the ability to access new forms of investments such as private loans which they could not before access safely, and it could even help micro businesses that can’t afford staffing to handle simple but tedious operations.
Data is protected and preserved
All data from contracts is preserved on the blockchain. Once submitted these arrangements can’t be altered, and they can’t be lost either. This provides a lifetime of protection for the participants.
There's also some problems with smart contracts.
While smart contracts can do some awesome things there are still some kinks in the system that need to be worked out before mainstream adoption can occur. Here’s some potential problems that still need to be addressed.
Smart contracts are not very user friendly yet
For the most part, smart contracts require specialized coding knowledge. That means that not only can everyday people not create smart contracts on their own but even people with experience in other coding areas may have trouble with them. That’s because they typically use their own programming languages which are not used for more common applications such as web development. Some projects are working on this, but we’re not there quite yet.
It’s questionable whether they would hold up as evidence
While the idea behind smart contracts is that they can eliminate the need for litigation, there are some cases where that may not be possible. If you have used a smart contract for example to prove ownership of a particular asset, especially a physical one, you may still need a court to actually enforce that ownership. It’s questionable whether a court or other authority figures would accept this contract as legally binding, and it may be awhile before they are formally recognized.
It may be difficult to edit contracts that are created
Due to the nature of the blockchain it may be difficult to edit contracts after they have been created. Mistakes happen, and users who are not very tech savvy are likely to make many of them. This could create some serious problems.
Want to see some example smart contracts?
One of the great things about smart contracts and blockchain projects is that much of the code is open source. This means that it’s easy to verify the legitimacy of these contracts since the code can be audited at any time and by anyone. It also provides a great opportunity to learn from others if you’re interested in creating your own contracts to use with various applications. Let’s take a look at a couple examples of smart contracts used in popular blockchain projects.
The Cryptokitties siring contract
Blockchain game Cryptokitties uses four primary contracts to manage the assets contained within their game. This particular contract is used to provide a way for users to auction the rights of their cats in order for other users to utilize them for siring. This gives the buyer the ability to breed a new cat that could potentially have more desirable traits. Here’s a peek at the code, but you can see the entire contract here.
Hydrogen Raindrop Contract
Raindrop is just one piece of Hydro’s banking puzzle, but this contract provides the backbone of their service. In the section of code that we can see here, the contract gives permission to banking applications to sign up users on their behalf for the service as long as they have given the application permission to do so. If you’re interested in seeing the entire contract, then check out the Github page to see more.
Want to start making your own smart contracts?
In many cases, even if you have prior coding experience you will still have some work to do to learn how to create smart contracts. Typically they are created using unusual programming languages that software developers in other fields are likely not familiar with. While this does give it a bit of a learning curve, it should also not be terribly difficult to grasp the basic concepts if you already have some coding experience elsewhere.
If you’re a beginner with little to no experience then have a look at Ethereum’s “Hello World” contract page. This resource will help you to understand the basics of smart contracts, and you can use this tool to get an idea of how everything comes together before moving on to more complex items. While this particular tutorial is for creating contracts using the command line, they do have a number of other tutorials which are pretty in depth, and their documentation is a great place to start if you want to get started with making your own smart contracts.