What Are Smart Contracts? – Blockchain Basics and Perspectives13 min read

What Are Smart Contracts? – Blockchain Basics and Perspectives13 min read

05/12/2018 0 By Vasyl Tsyktor

A concept of smart contracts arose back in 1994 due to Nick Szabo, a cryptographer and computer scientist. However, his idea became possible only with the rise of the blockchain technology, in particular, such elements as the decentralized consensus protocol, cryptographic cybersecurity, and public registry. Regardless of the newly discovered prospects, smart contracts are only gaining momentum, but they have a set of important concerns.

What is a smart contract?

A smart contract is a software transmitted in the form of code. It relies on the blockchain technology which in turn is a distributed ledger consisting of a wide range of computers connected within one decentralized network. Blockchain allows users to make transactions or transfer data without any intermediaries like banks or payment systems.

 

The definition of smart contracts implies the complete automation of the value exchange based on those predefined rules. You can think of a smart contract as a digital contract with automatically executed conditions signed by involved parties. One of the main advantages of smart contracts is that they are easy to conduct an audit for. In other words, a smart contract is a decentralized system with a set of functions that are easy to verify but impossible to modify.

How do smart contracts work?

A traditional contract signing process involves two or more parties that want to establish a cooperation or partnership based on certain rules. These parties create a paper document that describes each contract participants, their duties, and mechanism that guarantees the proper exchange of values as well as penalties for parties that will ignore the contract conditions. The document signing process also involves an intermediary like a notary who confirms the fact of making the agreement with his signature.

 

When some party violates the contract rules, the aggrieved party has to take all the evidence it has and go to a court. It can take years for judges to learn the case and determine offenders. Furthermore, culprits can get away from it if the initial contract has legal vulnerabilities.

Smart contracts vs. traditional contracts
Characteristic Smart contracts Traditional contracts
Form Software or transaction protocols based on blockchain Paper documents
Origins Created with code Created on a base of law
Language Written in a programming language Written in a legal language
Modification Contract rules can’t be modified Contract rules can be modified, replaced or misunderstood
Execution Contract rules get automatically executed by all involved parties. Involved parties can ignore or partially follow contract rules
Violations In the case of violations, the system automatically applies punishments set in the contract. In the case of violations, involved parties have to go to court.
Intermediaries Transactions happen without any intermediaries. Transactions involve a wide range of intermediaries such as lawyers and notaries.
Payment method Transactions use cryptocurrencies Transactions use cash or digital currencies.
Time The exchange of values happen immediately The exchange of values happens with delays.
Access to data All the information about involved parties, which can define data to be public, is stored in the blockchain. You can learn about involved parties only if they provide such information.
Geographic limitations Partners can sign a smart contract from anywhere in the world. Options of signing a traditional contract remotely are limited by a local law.
Guarantees Secure deal guarantees No guarantees
Security No fraud There is a chance of fraudulent actions, bribes, or corruption.
Creation Smart contracts are hard to create. The smart contract development requires programming skills. Simple traditional contracts are easy to create. Complex contracts require the assistance of lawyers.

Unlike traditional agreements, smart contracts combine both conditions and the strict mechanism of their execution. These conditions can’t be misunderstood, explained in a different way, or altered since they have a form of an algorithm rather than words.

 

The distributed ledger has one or more validators and a database that stores all smart contracts submitted for execution in a strict chronological order. For a smart contract to be properly configured, this database should contain all the triggers that will automatically perform smart contract rules.

 

In other words, transaction validators should have access to all the data related to a certain smart contract, for example, cryptocurrency accounts belonged to involved parties, their balances, user transactions, and timestamps. Smart contract triggers may be a certain time, exact successful transaction, etc. You can think of a transaction within blockchain as a digital event that may imply saving a particular piece of information or a payment with Bitcoin or any other cryptocurrency in the decentralized system formed by particular user computers called nodes.

 

The smart contract code example:

contract Mortal {
    address owner;
    function Mortal() { owner = msg.sender; }
    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}
contract Greeter is Mortal {
    string greeting;
    function Greeter(string _greeting) public {
        greeting = _greeting;
    }
    function greet() constant returns (string) {
        return greeting;
    }
}

How smart contracts work:

  1. When you make a transaction, each network node within the distributed ledger receives the information about the event
  2. The decentralized system confirms the transaction.
  3. After the confirmation, the system combines the transaction with other ones and forms a new unit of the digital registry and stores it in the blockchain.
  4. Once the data block is saved, the transaction gets complete.
  5. The successful transaction triggers a smart contract code: a seller receives money and a buyer received an item he or she has paid for.

 

To run a smart contract code, the system requires no Internet connection. This code works like vending machines: you simply insert a bitcoin into a machine (registry), and a service you’ve ordered comes to your account.

Platforms

To create and run a smart contract, you can use one of the existing platforms that provide different capabilities. These tools allow anyone with the appropriate coding knowledge to create smart contracts.

Smart contract platforms include:

  • Bitcoin. It’s the first blockchain platform that enabled developers to create smart contracts/ However, it was designed rather for cryptocurrency transaction rather for smart contracts.
  • Side Chains. Another blockchain platform with more advanced features than Bitcoin.
  • NXT. It’s an open online platform that provides a limited number of smart contract templates. Unfortunately, you can’t create a unique contract using NXT.
  • Ethereum. It’s an open online platform for building online services based on the blockchain. Ethereum charges per each smart contract.
  • EOS. Another blockchain platform that allows developers to create smart contracts for free.

Each platform may use a different programming language.

Programming languages

Developers create smart contracts with a code written in a certain programming language. Smart contract programming languages are:

  • Turing
  • Script
  • Solidity
  • Serpent
  • C++

For example, Ethereum relies on Solidity while Bitcoin developers use C++ to create smart contracts.

Use cases

Smart contracts are relatively a new phenomenon but a wide range of industries like automotive, fintech, and insurance have already begun to benefit from this blockchain-based technology. Below, we will cover a few smart contract use cases in these sectors.

Leasing a car


Smart contracts have great potential for the automotive industry. If you’ve ever tried to rent a car then you’re familiar with a routine and paperwork you have to come through before you start an engine. That’s why DocuSign partnered with Visa to bring their clients an easy, fast, and suitable way to lease a car without leaving its seat. To sign a smart contract, customers have to make only a couple of clicks using a touchscreen of the in-car infotainment system. These clicks include signing, choosing insurance options, and adding a credit card to the system. With the DocuSign’s platform, drivers can automatically pay for fueling, maintenance or music services.

Streamlining the compensation process


When you face a problem you have an insurance policy for, it often protects you from huge financial losses. However, you have a lot of paperwork to do and communications to conduct before you get your compensation. A French insurer AXA launched Fizzy, a pilot flight-delay Fizzy product based on smart contracts.

 

Those clients who have purchased Fizzy gets an immediate compensation once their flight delays. The smart contract is connected to global air traffic databases which enables the system “understand” when a delay occurs, thus eliminating the need for clients to send the evidence to the insurer and wait for the compensation. Therefore, the application of smart contracts helped AXA automate the compensation process.

Cryptocurrency exchange

The fintech sector is among pioneers when it comes to blockchain and smart contracts in particular. A British bank called Barclays held the first blockchain-based trading transaction in 2016. They started using smart contracts on a regular basis as a means of a tool for the exchange of values with other financial institutions. In fact, all cryptocurrency exchange operations happen due to smart contracts. When you buy bitcoins with your credit card, the blockchain-based system sends the cryptocurrency to your virtual account according to your smart contract that includes your payment data and the amount you want to buy.

Problems

Since smart contracts are based on the blockchain technology, the database that stores them is available for the global network of nodes. Therefore, wherever a particular member lives, he or she has access to a digital dynamic copy of the distributed ledger. Once a new transaction appears in the registry, each user computer connected to the blockchain network get an updated ledger copy.

 

It makes smart contracts useful only in cases where involved parties use a public database and they make changes to it on their own without any intermediaries. Furthermore, involved parties have to use private keys besides public ones to access digital assets. Otherwise, the use of a smart contract doesn’t make sense since your contract becomes vulnerable and easy to alter.

Therefore smart contracts have the following problems:

  • Lack of legal regulation
  • No binding to a specific territory or jurisdiction
  • Using only cryptocurrencies for transactions
  • Creating smart contracts based on a structure of traditional contracts
  • Lack of the necessary infrastructure and user support
  • Choosing a suitable programming languages
  • Lack of cybersecurity

Lack of legal regulation

In many countries, companies create and sign smart contracts using the “Everything which is not forbidden is allowed” principle.  However, the lack of legal regulation in this field can lead to the fact that entrepreneurs may hesitate to use this technology to avoid penalties from legal authorities. Although, both Tennessee and Arizona states have already legalized smart contracts and even more countries to come in the near future.

No binding to a specific territory or jurisdiction

Based on the “If-Then” model, a smart contract makes it impossible to determine the jurisdiction this document should rely on. This forms a lot of issues for judges to deal with the case where something has gone wrong. However, involved parties can’t just cancel a signed smart contract or ignore its rules. Both conditions and penalties get executed automatically which eliminates any disputes. This principle makes any legislation unnecessary when two sides have made an agreement using blockchain.

Using cryptocurrencies for transactions

Cryptocurrencies are illegal in many countries like China and Bolivia. This makes impossible for customers and entrepreneurs in such countries to create and sign smart contracts. The solution can be using stablecoins, cryptocurrencies pegged to real currencies or other assets. For example, Tether stablecoins are said to be pegged to the U.S. dollar. However, Bloomberg wrote that managers of Birfinex, a company behind this cryptocurrency, couldn’t prove they had bank accounts. Furthermore, US Department of Justice started investigating the case of the artificial increase of Bitcoin rates with the use of Tether.

 

Existing stablecoins include:

  • Tether USDT
  • USD Coin
  • MakerDAO
  • USDX
  • Havven
  • Basecoin
  • TrueUSD
  • Gemini Dollar

Another advantage of stablecoins is that they don’t have those extreme graph oscillations compared to usual cryptocurrencies such as Bitcoin or Ethereum.

Creating smart contracts based on a structure of traditional contracts

Smart and traditional contracts have totally different principles. While some phrases can sound unclear and, as a result, lead to unexpected consequences for an unaware party involved in a certain traditional contract, smart contracts contain clear algorithms that, for example, lock car doors if a car lessee doesn’t pay for a vehicle. Smart contracts revealed how imperfect traditional contracts are. That’s why the latter can’t be a legal base for creating smart contracts.

Lack of awareness and trusted data sources

When a smart contract has triggers that involve external data like air temperature or air traffic, there appears an issue which sources to use in order to extract such information and how to get a proof of concept. Furthermore, since blockchain is relatively a new technology, there’s an unawareness and lack of trust to it among ordinary Internet users and even small and medium enterprises. This may be a question of time, but until that moment, smart contracts will remain a prerogative of innovative startups and companies.

Choosing a suitable programming language

One of the most popular programming languages for creating smart contracts is Solidity. As of November 2018, the last version is 0.5.0, but developers have been already working on the next 0.5.1 update. This proves that smart contract programming languages are still imperfect and require a lot of improvements until they become Turing complete or, in other words, until they can describe any mathematical algorithm.

 

Moreover, only developers can understand the capabilities of particular programming languages, That’s why lawyers have approach coders for assistance which makes the main idea of smart contract worthless. In this case, coders become intermediaries. Therefore, businesses will need an easy-to-use software based on a drag-and-drop principle that will enable companies to create smart contracts without any assistance.

Lack of cybersecurity

Blockchain is supposed to be a highly secure technology that ensures nobody can modify data stored in the distributed ledger. However, smart contracts based on Blockchain have vulnerabilities similar to traditional contracts which sounds weird enough. While the text of traditional contracts influences their security, the code of smart contracts defines how protected these innovative documents are. This is where the human factor rises in those technologies designed to eliminate it.

 

According to a recent report by young scientists from the U.K. and Singapore, 34,000 Ethereum-based smart contracts contain bugs. This puts $4.4 million in the cryptocurrency equivalent at a significant risk. The history already knows the case with the Parity smart contract-based wallet where one bug affected up to $146 million in ETH. Furthermore, the code should be secure enough in order to disable hackers to exploit it. So smart contracts are as smart as their creators are.

The future of smart contracts


Despite a number of concerns, smart contracts have a great potential to replace traditional contracts in a couple of decades in such countries as Canada and United States as well as the European Union members. However, legal authorities should improve current legislative systems in order to make this technology available among companies across the globe.

 

In addition, smart contracts can become common only if they become easy to use for SME’s. Special tools will minimize the human factor and bugs that can lead to massive financial losses. Programming languages behind smart contracts also need improvements to enable developers to create any algorithms and rules that make this technology Turing complete and self-sufficient.