A Guide to Smart Contracts and Their Implementation
- 34086 views
- 12 min
- Jan 16, 2018
Along with blockchain technology, smart contracts are of intense interest to businesses.
To provide our readers with a thorough understanding of what smart contracts are and how exactly they impact the way modern businesses make deals, we've prepared this guide.
The Centralized Business Model is Giving Way to Decentralization
In the traditional centralized model of business relationships, there’s always a third party that stands between the two parties that are making a transaction and affirming the terms and conditions in a contract. This third party may be a banking institution, a law enforcement company, a government establishment, or some other intermediary.
When building relationships within a centralized model, businesses are dependant on intermediaries, which puts customers at risk. Besides, central systems can’t guarantee payments and implementation of contracts.
The development of blockchain technology, which allows businesses to build decentralized models, opens new horizons for businesses to conduct transactions and make agreements. And one of the technologies that’s proposing an alternative to the traditional model is the smart contract.
Smart Contract Concept
Although smart contract hype has grown with the hype around blockchain technology, the term smart contract actually appeared over twenty years ago. Nick Szabo, a computer scientist and cryptographer, wrote an article about smart contracts all the way back in 1995.
The concept that Szabo offered precisely corresponds to what smart contracts offer today, including the idea of implementing and storing smart contracts within a distributed ledger.
So what exactly is a smart contract?
What’s a Smart Contract?
A smart contract is similar to a contract in the physical world, but it’s digital and is represented by a tiny computer program stored inside a blockchain.
More specifically, a smart contract is a piece of software that stores rules for negotiating the terms of an agreement, automatically verifies fulfillment, and then executes the agreed terms.
What’s the main idea of a smart contract? Since a smart contract removes reliance on a third party when establishing business relations, the parties making an agreement can transact directly with each other.
Consider the example of a crowdfunding platform where product teams share their projects and collect money from supporters until a goal is reached.
If such a platform is centralized – like Kickstarter, for instance – then it acts as a third party between product teams and supporters who donate their money. This means both sides need to trust Kickstarter and, in fact, pay an additional fee to Kickstarter to serve as an intermediary.
A smart contract, alternatively, can perform the same crowdfunding actions – sharing projects, setting goals, and collecting donations – but without a third party. Simply put, we can program a smart contract to execute all of these actions.
More precisely, we can program a smart contract to receive funds until a goal is reached. If the project gets fully funded before the deadline, the money raised automatically goes to the product team. If the project fails, the money automatically goes back to supporters.
Since a smart contract is stored inside a blockchain where all data is stored in a distributed manner, no one is in control of the money. In a decentralized business model, smart contracts replace any other trusted third party. This leads to a pretty valid question:
Why Trust a Smart Contract?
Smart contracts are designed and implemented within blockchains, and therefore they inherit some of the blockchain’s properties:
- They’re immutable, which means a smart contract can never be changed and no one can tamper with or break a contract.
- They’re distributed, which means that the outcome of the contract is validated by everyone in the network, just like any transaction on a blockchain. Distribution makes it impossible for an attacker to force control to release funds, as all other participants would detect such an attempt and mark it as invalid.
How a Smart Contract Works
A smart contract is a program, or more simply put, code. The code behind a smart contract contains specific terms that are executed when triggered by specific agreed events.
Let's consider an example of how a smart contract might work if Alice is renting an apartment in Los Angeles and Bob from New York is looking to rent an apartment for his journey there.
A Logically Behaved Algorithm
Typically, Alice and Bob would use some platform that unites hosts and guests to agree on renting. This kind of platform would serve as a third party and would certainly take responsibility for compliance with the agreed terms. However, both Alice and Bob would be charged a fee by the platform. Besides, if either of them failed to fulfill their commitment, dispute resolution may be time-consuming and require a detailed review.
If Alice and Bob instead make an agreement using a smart contract, the smart contract will behave logically based on its algorithm and will guarantee that all the agreed terms and conditions are fulfilled. Immutability, which is in the DNA of a smart contract, won’t let Alice or Bob cheat.
Thus, the following terms and events can be set out in a smart contract between Alice and Bob:
- Independent storage is created, where both Alice and Bob can put value but can’t easily take out.
- Bob puts money for rent in storage.
- Alice puts the address and the code to her apartment in storage.
- Alice gets payment confirmation and Bob receives the address and apartment code.
- If Bob comes to LA and the address and code provided by Alice are right, Alice gets the payment.
- If it appears that the address or code supplied by Alice are wrong, Bob gets his money back.
- If Bob doesn’t come to LA, Alice gets her liquidated damages payment and Bob gets the rest of what he paid.
- At the end of the agreement, the smart contract is considered fulfilled and remains stored in the blockchain network.
This set of conditions and events represents the most basic one-time smart contract. Setting up terms in the code of a smart contract ensures satisfactory fulfillment.
Overall contract fulfillment is guaranteed by the blockchain technology itself, as a complete copy of the blockchain is publicly stored by all network participants and the smart contract remains immutable.
The Logic of the One-Size-Fits-All Smart Contract
Once Alice generates a smart contract that automatically and transparently works for her when renting out her apartment to Bob, she might think about creating a universal agreement for all further renters so she doesn’t need to create a new smart contract for each new guest.
With this universal agreement, anyone on the blockchain network can rent Alice’s apartment by following the algorithm above: the potential guest transfers rent payment, gets the address and apartment code, and then Alice gets her payment if everything works according to the contract terms for both sides.
Moreover, smart contracts can be even more universal. We could program a smart contract to be used not only by Alice but by any person who wants to rent out his or her flat. And certainly, smart contracts can contain more specific conditions, such as automatically adjusted prices, discounts, partial payments, and nearly any other imaginable option.
Blockchain Networks Using Smart Contracts
Much has been said about smart contracts in relation to blockchain technology. While there are plenty of examples of smart contracts implemented within different blockchain networks and projects, the most notable remain Bitcoin and Ethereum.
Though Bitcoin is mostly known for transactions of the Bitcoin cryptocurrency, its protocol can also be used to create smart contracts. Bitcoin provides a programming language that allows for custom smart contracts like multisignature accounts, payment channels, escrows, and time locks. In particular, there’s a separate smart contract platform called RootStock built on Bitcoin’s blockchain.
Ethereum is the most prominent smart contract framework, created and designed especially to support smart contracts. This framework, programmed in the Solidity language, is a decentralized platform that runs smart contracts without any possibility of downtime, censorship, fraud, or third-party interference. The Ethereum blockchain database stores transactions between people, transactions involving smart contracts, and their source code.
Smart Contract Benefits
Explicit programming algorithms in core and blockchain properties like decentralization, transparency, fraud resistance, and others make smart contracts a credible alternative for establishing business relations and performing transactions.
As an alternative to traditional contracts with a central business model, here are the benefits that smart contracts offer businesses:
- Direct dealings with customers. Smart contracts remove the need for intermediaries and allow for transparent, direct relationships with customers.
- Resistance to failure. Since businesses aren’t dependent on a third party, no single person or entity is in control of data or money. Decentralization means that even if any individual leaves the blockchain network, the network will continue to function with no loss of data or integrity.
- More trust. Business agreements are automatically executed and enforced. Plus, these agreements are immutable and therefore unbreakable.
- Fraud reduction. Since smart contracts are stored in a distributed blockchain network, their outcome is validated by everyone in that network. Therefore, no one can force control to release other people’s funds or data, as all other blockchain participants would spot this and mark such an attempt as invalid.
- Cost efficiency. Eliminating intermediaries removes additional fees, allowing businesses and their customers not only to interact and transact directly but also to do so with low to no fees for transactions.
- Record keeping. All contract transactions are stored in chronological order in the blockchain and can be accessed along with the complete audit trail.
Smart Contract Use Cases
Smart contracts are gaining popularity and have already been implemented in various blockchain projects. Here are just several promising examples of smart contract implementations in different industries.
Banking might be the primary industry where smart contracts appear to be the most significant alternative to the traditional model of transactions. Smart contracts make payments as well as loans, and nearly all others financial operations literally automated.
KYC-Chain implements smart contracts for individuals, businesses, and financial institutions. In the core of KYC-Chain are mechanisms allowing clients to comply with regulatory norms, such as automatic smart checks, as well as to share pertinent documents and get them digitally attested by notaries and institutions.
Smart contracts can also improve healthcare. They can streamline processes for insurance trials, increase access to cross-institutional data, and boost confidence in patient privacy. Authentication, authorization, and identity confirmation remain open issues for smart contracts executed on blockchain networks.
An example of smart contracts in the healthcare industry is Dentacoin. Dentacoin aims to bring patients and dentists together in communities to improve dental care and make it affordable worldwide.
Another area where smart contracts can provide real-time visibility is supply chains. Smart contracts ensure granular inventory tracking, benefitting supply chain financing as well as reducing the risk of theft and fraud.
Smart contracts can effectively be used regardless of marketplace type or goods sold. For example, Name Bazaar is implementing smart contract technology within a peer-to-peer marketplace where users can exchange cryptographic assets on the blockchain in the form of domains.
The traditional model of resolving legal issues and certifying documents is also giving way to smart contracts. Smart contracts eliminate the need for notarization, offering not only an automated and unbiased but also a cost-efficient solution.
Nottar.io illustrates the concept of notarizing documents using the Ethereum blockchain.
You’ve already read about the easiest concept of how a smart contract can work for real estate in the How Smart Contracts Work section. Of course, real-life projects are way more complicated and comprehensive and need to cover a broader range of issues and opportunities.
For instance, FOAM is a stock market for real estate that uses technology to let users make property transactions, get financing and funding, and manage leases.
It might be most interesting to investigate the potential impact of decentralization technologies on monopolistic spheres, especially government systems.
Australian company Horizon State is working to provide voting and other tools to help the democratic process. Particularly, Horizon State intends to offer a blockchain-based voting ecosystem that supports secure, cost-effective campaign operations for a range of election types and voting parameters. The primary goal of Horizon State is to enable transparent, unbiased voting in countries around the world.
Internet of Things Networks
There are areas where smart contracts intersect with other technologies, and the Internet of Things (IoT) is one of them. A combination of smart contracts and IoT is powerful and can enable significant transformations across industries, paving the way for new distributed applications.
Project Oaken is proving that. Oaken provides autonomous IoT hardware and software coupled with blockchain technology. Altogether, these components make it possible to use Oaknen with nearly any device to build an IoT network and therefore apply it to various real-life needs.
Unlike the traditional centralized business model, smart contracts foster a new kind of business relationship built on trust.
By inheriting blockchain properties, smart contracts offer immutability and distributed storage, which is what distinguishes them most from traditional agreements. Immutability and distributed storage allow smart contracts to become a credible means for making business agreements and performing transactions.
Blockchain technology is already impacting businesses. Of course, it is hard – or even impossible – to revolutionize the way industries operate with the snap of a finger. Significant changes take time. However, successful and promising use cases for the blockchain and smart contract technologies in particular are laying the groundwork for the future of business.
Interested in more articles about technology? Subscribe for our email newsletter below and be the first to get updates!
Subscribe via email and know it all first!