• Market Cap
    $400.184B 0.46%
  • POW Market Cap
    $308.251B 1.74%
  • POS Market Cap
    $19.939B -0.43%
  • Masternodes Market Cap
    $1.244B 1.96%

What are smart contracts?

By Inkarias - 2019-10-23

Often associated with the Ethereum protocol, which is positioned as a more programmable version of Bitcoin, the term "smart contract" has become popular only very recently, although the legendary cypherpunk, Nick Szabo, has written on the subject for the first time in 1994. Nick was a legal scholar and cryptographer and came to a conclusion that any decentralized ledger can be used as self-executable contracts which, later on, were termed as Smart Contracts. He imagined that these digital contracts could be converted into codes and allowed to be run on a blockchain.

Ethereum

It was not until 2015 and the deployment of Ethereum to see a first application of smart contracts. These represented the central point of Ethereum, a point that can be felt in the official whitepaper of the project. Today, with the advent of distributed consensus protocols and crypto-currencies invented to allow borderless, secure, censorship-resistant and programmable digital value exchanges, it is a whole technological sector opening up to contract programming. Ethereum is the best-known protocol for programming smart-contracts, but it's not the only one, and smart contracts can now be deployed on other competing blockchains.

In this document, we will particularly take the Ethereum project, led by Vitalk Buterin, as an example, since it was one of the forerunners of the adoption of smart contracts as we know it today.

Smart contract: definition

Contract

Smart contracts are irrevocable computer programs, most often deployed on a blockchain, that execute a set of pre-defined instructions. The main idea behind this concept of smart contracts is to guarantee the binding force of contracts no longer by law, but directly by the computer code: "code is law".

As with every computer program, the complexity varies from one smart contract to another. Some implement simple conditions, like an "if" function (if this condition is fulfilled, then the contract is executed) whereas other smart contracts are incredibly complex and sometimes hard to understand. To illustrate, some smart contracts even have the ambition to replicate all clauses and rules allowing companies (commercial or otherwise) to function. In this regard, we often speak of DAO, acronym for Decentralized Autonomous Organization. It should be noted that often, complexity is the enemy of security.

In short, we can specify this definition by summarizing these particular contracts in four points:

  1. A smart contract is an agreement between several parties in the form of computer code.
  2. They are distributed and therefore stored in a public database and cannot be modified, altered or falsified on top of blockchain.
  3. They allow transactions to be performed automatically without the need of a third party, thus relying on no one.
  4. Automated transactions occur when one or more conditions of the contract are met.

How do smart contracts work?

How it works?

The smart contract offers a sort of computer equivalent of the paper contract. During the execution of a smart contract, all the validation steps are recorded in the blockchain used (most often Ethereum), this process makes it possible to secure all the data by preventing their modification or their subsequent deletion.

In practice, the vast majority of smart contracts are used to automate value exchanges in the form of cryptoassets. All accounting entries relating to these exchanges of numerical values ​​are systematically entered in the blockchain. In this way, all asset transfers are public, predictable and irrevocable. Anyone can check on the blockchain the good performance of the smart contract and determine who the asset belongs to.

Smart contracts therefore guarantee an extremely loaded set of execution conditions, which normally leave no room for doubt or confusion. The conditions are very clearly set, and the interpretation of the code is unequivocal, contrary to the human interpretation, which always leaves room for negotiation or the discovery of a flaw.

Most intelligent contracts are standardized, as are paper contracts, for which we have the option of using templates. The best-known smart contract standard is known as the ERC-20, and its main function is to enable the creation of tokens (digital assets, cryptocurrency) on the Ethereum network. More standards such as ERC721 for collectibles ( CryptoKitties Dapp for example) arrived and brought more possibilities to implement smart contracts for various utilization.

How does a smart contract on Ethereum Blockchain work?

Ethereum smart contracts are based on a programming language: Solidity. This language, still nameless when writing the white paper, was described by Vitalik Buterin :

« What Ethereum intends to provide is a blockchain with a built-in fully fledged Turing-complete programming language that can be used to create "contracts" that can be used to encode arbitrary state transition functions, allowing users to create any of the systems described above, as well as many others that we have not yet imagined, simply by writing up the logic in a few lines of code »

These contracts have a wide range of possibilities:

  • Function as multisignature accounts implementing additional conditions, such as the fact that funds can be spent only when a certain percentage of signatories agree.
  • Manage agreements between users, such as conventional contractual agreements.
  • Can be used by other contracts, so that they "deport" certain features on existing contracts.
  • Store information from an application, such as the registries of the application members.

Once the different procedures and conditions of these contracts are coded, they are deployed on Ethereum and executed in the Ethereum Virtual Machine, also commonly called EVM.

It is a kind of decentralized operating system through the nodes of the Ethereum blockchain, and in which smart contracts are executed. To be run smoothly by the EVM, contracts must meet three criteria and must be:

  • Deterministic (for the same arguments, the functions of the contracts must always return the same result)
  • Finalizable
  • Isolated

The problem lies in the fact that for some programs, it is not possible to know if it will be finalized one day or if it will fall into an infinite loop. It is to avoid the problem of infinite loop that gas has been implemented on the Ethereum network.

This unit of measure, in the form of fees, makes it possible to define the duration during which an Ethereum contract or transaction will be executed on the blockchain.

Advantages and Drawbacks of Smart Contracts

Public blockchains offer great opportunities to deploy smart contracts in an extremely secure way. There are currently hundreds of ERC-20 tokens (all cryptocurrencies from a ERC-20 smart contract) with a global valuation of billions of dollars.

The advantages of smart contract are multiple and important. These allow to:
  • Secure an agreement between two parties (or more) thanks to the transparency and immutability of blockchains
  • Automate payment and eliminate the risk of delinquency, commonly seen in a traditional contract
  • Reduce drastically the intermediate costs in the elaboration, the follow-up and the conclusion of a contract (notary, lawyer, bank delays)
Smart contracts, however, have drawbacks that are currently being addressed by specialists in blockchain and distributed register technologies. The main drawback is the risk of flaws, inherent in any computer program.

The code of smart contracts is most often open source, but if this code is poorly designed, it can allow hackers to exploit the vulnerabilities it contains to the detriment of other users. The best-known example of hacking is The DAO case, which resulted in a loss of more than 150 million dollars (in ethers). Following this famous hack, the Ethereum community had made the painful choice to re-write the transaction history listed in the Ethereum blockchain after in order to dispossess the hacker of his loot and return the stolen ethers to all the victims.

This type of problem raises the question of the immutability of blockchains ("Code is Law") in the face of the need to reintroduce human intervention as part of a smart contract in order to restore morality and public order. A doctrine exists, arguing that it would be conceivable to add a form of governance additional to blockchains orchestrated by smart contracts to define possible cases of arbitration in case of emergency. In contrast, the Bitcoin purists and its evolution are in favor of preserving these ecosystems as much as possible from all human and political intervention.

Examples of smart contract

We won’t introduce raw code as it could be too technical to understand in a few lines, however, numerous use cases showed up with the introduction of smart contracts in our modern society.

Several blockchains offer the possibility of deploying smart contracts: the best known is of course Ethereum, which already includes many decentralized applications programmed via smart contracts. But other promising protocols, such as EOS, Tezos, or Cosmos also make it possible to program smart contracts. The Cardano blockchain also provides this possibility, guaranteeing a level of security adapted to the most critical systems.

Smart contracts offer a wide range of possibilities to implement this system in today's businesses. Certain industrial and / or market sectors could benefit greatly from the arrival of smart contracts in the information systems already in place ( the possibilities aren’t limited to the three sectors below and smart contracts could be implemented in many more industries).

Insurance

  • An automated insurance service through smart contracts. This service automatically compensates passengers on a flight that has been delayed for more than 2 hours.

Health Sector

  • Traceability of organ transplant management, participated.
  • Traceability and management of all related health data across the world.

Administrative and Company Management

  • Smart contracts can be used as part of running a business. For example, all salary payments can be automated simply and reliably.
For now, the most proven smarts contracts are programmed on Ethereum and are listed on https://www.stateofthedapps.com and are what we commonly call Dapps (We will introduce the notion of Dapp and the functionalities in our next review).

Applications:

  • Decentralized Currency Exchange: 0x, OmiseGo, MakerDAO
  • Games on Blockchain: Cryptokitties, My Crypto Heroes, Etheremon
  • Gambling: Playtowin, FunFair
  • Decentralized cloud: Storj, iEx.ec
  • Predictive market platforms: Augur, Gnosis and more

ICO / STO

It is not easy to talk about smart contracts without mentioning ICO (Initial Coin Offering) or STO (Security Token Offering) as numerous projects chose these kind of crowdfunding for their projects. Both are modes of financing allowing the creators of tokenized projects to organize pre-sales of tokens. They also work through smart contracts, the ERC-20 standard is used by ICOs and the ERC-1400 standard for STOs.

However, since 2017, ICOs tend to disappear to make way for more modern, traditional and secure investment methods for all investors. It is important to note that investment opportunities with smart contracts are unlimited.

The smart contract economy is still in its infancy but seems to have a very bright future. Many decentralized applications in the health sector, insurance, or supply chains (pharmaceuticals, agri-food, cosmetics, etc.) are currently under development. The 2020s are likely to offer a significantly different organization than our current version of paper contracts and applications governed by trusted third parties. An economy in which cryptocurrencies will play a vital role.