smart contracts

A smart contract is a computer program or code whose execution does not require the intervention of a trusted third party. In the context of the blockchain, it is a program that is automatically activated on a distributed network when certain conditions are met on the shared registry.

Smart contracts were conceptualized by Nick Szabo as early as 1994, but it wasn’t until 2009 and Bitcoin to see their first implementation in a viable system. These standalone contracts are now widely implemented on the specialized Ethereum platform, launched in 2015 for this purpose.

Origin of smart contracts

The smart contract concept was formalized by the American computer scientist, lawyer, and cryptographer Nick Szabo. In his first public writing on the subject in 1994, he described it as “a computerized transaction protocol that executes the terms of a contract”. He later refined his idea in various writings such as Smart Contracts: Building Blocks for Digital Markets in 1996 or Formalizing and Securing Relationships on Public Networks in 1997.

The term “smart contract,” coined by Szabo himself, is confusing because a smart contract is not really smart, nor is it really a contract in the legal sense, but is a program that runs on simple terms. Szabo coined this expression for communication: the word smart is regularly used to support new technology’s clever and evolving side. A multifunction phone is thus called a smartphone. A smart card is a smart card. We talk about smart cities for a connected city, smart bombs for guided bombs, etc.

Although it attracted the attention of many cypherpunks in the 1990s, the concept of smart contract was not implemented because no technology was available at the time to implement it in a sufficiently robust way. It was not until the emergence of blockchain technology with Bitcoin’s appearance in 2009 that the idea was actually implemented: although its ability to manage contracts is limited, it is, in fact, a programmable currency system.

The real revolution comes in 2015 with the launch of Ethereum, which enables more complex autonomous contracts to be built, in particular using a specific programming language called Solidity. The latter allows developers to write advanced processes in a short period of time.

This emergence allowed many other platforms based on the same model to appear, such as Tezos, Cardano, EOS, NEO, or TRON. The rise of these protocols has allowed the idea of the intelligent contract to be reborn to automate and improve many processes. An intelligent contract makes it possible to dispense with intermediaries, and therefore trusted third parties to implement certain clauses in the contract.

What is a smart contract?

Smart contracts are computer programs that run without the intervention of a trusted third party, usually on a blockchain such as the one from Ethereum. They are made up of clauses, which are the conditions that must be met for a part of the contract to be applied. These conditions are defined beforehand by the creator of the contract and are written in an immutable way on the blockchain. The contract can then be automatically triggered when certain conditions are fulfilled on the chain. Contrary to a traditional contract, no third party will proceed to the realization of the contract, everything is automated.

On the Ethereum blockchain, created by Vitalik Buterin, a smart contract is identified by a public address for example 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f. In addition to managing ether transactions, this address contains code and data, necessary for the proper functioning of the program. Contrary to a classic account that asks a person to sign the transactions, a contract will react autonomously to the different interactions.

Contrat d'Uniswap V2 Etherscan

For example, a lottery can be set up through a smart contract: one person deploys the contract to an address, and everyone can then buy a ticket by interacting with the contract. Two clauses can be implemented :
  • If on a given date, the account balance exceeds a certain amount, then it is sent to a randomly selected participant.
  • Otherwise, participants are refunded.
This is just one example and the possibilities offered by autonomous contracts are much wider than that: representation and transfer of assets (tokens, deeds, etc.), games of all kinds, decentralized exchange services, loans, decentralized autonomous organizations, etc.
Smart Contracts
Note in passing that smart contracts form the basis of what are called decentralized applications or dApps.

Which programming language?

Each blockchain for managing autonomous contracts has what is called a virtual machine, which runs simultaneously on each computer on the network and interprets the different transactions. The contracts are thus interpreted in the same way by all the nodes and it is thus necessary to have a language to communicate them between the different machines.

As mentioned above, the first contracts were deployed on the Bitcoin blockchain. This was possible because Bitcoin is a programmable currency system in which all transactions are contracts: thanks to a language, simply called Script, a Bitcoin coin can be blocked under certain predefined conditions. Typically, most funds are blocked at one address by a script like :


Nevertheless, the Bitcoin virtual machine is not Turing-complete and is deliberately limited to procedural operations. For example, it is impossible to perform loops and recursivity with the Script language. This is the reason why Ethereum was created: to constitute a versatile and decentralized global computer that allows the execution of an extreme diversity of autonomous contracts.

Ethereum’s virtual machine (Ethereum Virtual machine or EVM) was thus thought to be almost Turing-complete: it is possible to perform loops and recursions, but it is limited by a gas system so that a contract cannot run ad infinitum and paralyze the network. It is based on a bytecode similar to the Bitcoin Script. Nevertheless most contracts are usually written in a higher level language, which is compiled in bytecode, which makes the developer’s task much easier. The most widespread is the Solidity language, a language inspired by Javascript, created in 2014 at the initiative of Gavin Wood and regularly updated since then.

Here is a simple example of a contract written in Solidity (example from Mastering Ethereum). It is a “faucet” system that gives ethers (ETH) free of charge to the person who asks for them in the contract:

pragma solidity ^0.4.19;
contract Faucet
    // Function giving ETH
    function withdraw(uint withdraw_amount) public
        // Limit of withdrawal amount is 0.1 ETH
        require(withdraw_amount <= 100000000000000000);
        // Send the amount to the address that requested it
    // Contract allows the incoming payments
    function () public payable {}

Bitcoin and Ethereum are not the only protocols that support smart contracts: virtually all Cryptocurrency systems have programming capabilities, with the exception of a few systems such as Monero.

Why do we use Smart Contracts?

Although not yet exploited to their full potential, stand-alone contracts are useful for all sorts of things. The current uses are many and varied, but they will, most of the time, come closer to the financial field.

Here are a few examples of smart contract applications :

  • Multi-signature accounts: these allow the setting up of joint accounts requiring several signatures to make transfers.
  • Escrow payment, which allows the sequestration of funds awaiting the delayed sending of an asset. This type of contract is, for example, implemented by the LocalCryptos peer-to-peer buying/selling platform.
  • Payment channels, which give two users the possibility to make micropayments between them. It is on these channels that the Lightning network is based.
  • The representation of assets on a chain of blocks by a token: this is called tokenization. This can concern fungible assets (such as stable corners backed by fiat currencies) and non-fungible assets (such as real estate with RealT).
  • Fundraising, which is mostly based on the presale of a digital token with future utility. We speak of Initial Coin Offering (ICO), Initial Exchange Offering (IEO), or Security Token Offering (STO) depending on the context and nature of the token.
  • Decentralized exchanges of cryptocurrencies. This can concern cryptocurrencies on different channels (via atomic swaps) or cryptos on the same channel (Uniswap, Kyber Network, Binance DEX, etc.).
  • Decentralized lending, with Maker and Compound, for example.
  • The predictive market with Augur.
  • Decentralized autonomous organizations, such as Maker DAO or Moloch DAO.

Note that most of these examples can be categorized as belonging to decentralized finance.

Many other use cases have not yet been fully exploited. These include :

  • The notary’s office allows the automation of processes such as birth certificates, property transfers, etc., which are not yet fully exploited.
  • Insurance: Driving in clear weather and on a clear road would give a different compensation than driving at night on a bumpy road.
  • According to its customers’ orders, the supply chain would automatically order the number of parts needed to produce a given product.

These examples would require the existence of so-called oracles that would make sure to enter real-world data into the blockchain. This raises the question of reliability: can an oracle be trusted for its decentralized application? Today, oracle systems do exist, but they need to be improved.

What are the risks?

As with everything in IT, the main risk with smart contracts is the risk of hacking.

Since the code is published on the chain, it is possible for a hacker to identify its weaknesses and exploit them. This has already happened several times on Ethereum, and for extremely high amounts: the best known case is the hacking of TheDAO’s contract on June 17, 2016, which allowed someone to seize 3.6 million ethers, or more than $150 million at the time. This case led to the split between Ethereum (ETH) and Ethereum Classic (ETC): Ethereum chose to cancel the transfer in order to reimburse TheDAO’s investors, whereas Ethereum Classic preferred to follow the principle of immutability.

Thus, before proceeding with the deployment on the network, one must make sure that everything works well in the code one has written, because it is impossible (in principle) to modify or stop a contract if one has not programmed it to. There are ways to mitigate the risk of hacking, including :

  • The use of standards that have been verified and tested by the community, for example the ERC-20 standard, which is widely used to create new tokens on Ethereum.
  • The use of audits by specialized firms.

What is the legal value of smart contracts?

A common mistake that many beginners make is to believe that a smart contract is a contract in the legal sense. This is not the case! They are simply computer programs running on distributed systems that apply predefined clauses, hence the analogy with contracts.

Smart contracts currently have no legal value. If, in one way or another, the funds in your contract are siphoned off by a hacker, there is no recourse because it is not considered theft.

Nevertheless, it is possible that in the future (and with the maturation of the different crypto-economic protocols) legal systems will recognize the validity of the information located on certain channels. In reality, the idea is not to adapt the different blockchains to the existing legal system, but to make the whole legal system, in the long run, rest on these blockchains.

Moreover, even if the governance systems of the blockchains can sometimes repair a fault, as was the case for the TheDAO piracy that was cancelled on Ethereum, it should be specified that such measures can only take place when the security of the channel is at stake (here 4.5% of the stolen ethers). In this way, the accidental freezing of more than 500,000 ETH ($150 million) of the Parity contract in November 2017 was not significant enough to reverse the process.