What is a Smart Contract?

0
72
What is a Smart Contract?
What is a Smart Contract?

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

Smart contracts were conceptualized by Nick Szabo starting in 1994, but it took until 2009 and Bitcoin to see their first implementation into a workable system. These autonomous contracts are now widely implemented on the specialized Ethereum platform, launched in 2015 for this purpose.

Origin of Smart contracts

The concept of smart contract was formalized by 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 a bit confusing because a smart contract is not really smart, nor really a contract in the legal sense , but is a program that runs under simple terms. Szabo coined this expression for communication: the word smart in English is indeed regularly used to emphasize the clever and evolving side of a new technology. A multifunction phone is thus called a smartphone in English., 

Although it attracted the attention of many cypherpunks in the 1990s, the concept of smart contract was not implemented because there was no technology at the time to implement it in a sufficiently robust way. It was not until the emergence of blockchain technology with the appearance of Bitcoin in 2009 that the idea was really implemented. Although its ability to manage contracts is limited, the latter is indeed a money system.

The real revolution came in 2015 with the launch of Ethereum, which allowed the construction of more complex autonomous contracts, particularly by using a specific programming language called Solidity. The latter will enable developers to write advanced processes in a short period of time.

This emergence has allowed many other platforms based on the same model to appear, such as Tezos, Cardano, EOS, NEO and TRON. The rise of these protocols has allowed the idea of ​​the smart contract to be reborn to automate and improve many processes. A smart contract makes it possible to do without an intermediary, and therefore a trusted third party,  to carry out certain clauses provided for 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 like Ethereum. They are made up of clauses, which are the conditions that must be met for part of the contract to be enforced. These conditions are defined beforehand by the creator of the contract and are written immutably on the blockchain. The contract can then be automatically triggered when certain conditions are met on the chain. Unlike a traditional contract, no third party will carry out the contract, and 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 transactions in ethers, this address contains code and data necessary for the proper functioning of the program. Unlike a traditional account which asks a person to sign the transactions, a contract will react on its own to the different interactions autonomously.

rqWbGSAwVtkMqAvXvUuvilYyK6 nxqbr7ERgLwWDZku43I8tLBeE1jIXPsd Ra rPWptGxE3IQdOgaIfs090dKiajyg8eP r yGDXTCkuXRnyj2ckBRqmKHfLcoM11uMRaK4sidPMxnV 3Hm4A

For example, a lottery can be implemented through a smart contract: a person deploys the contract at an address. 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 chosen participant.
  • Otherwise, participants are reimbursed.

This is just one example, and the possibilities offered by autonomous contracts are much broader than that: representation and transfers of assets (tokens, deeds of property, etc.), games of all kinds, decentralized exchange services, loans, decentralized autonomous organizations, etc.

What is Programming Language?

Each blockchain for managing autonomous contracts has what is called a virtual machine, which runs simultaneously on each computer in the network and interprets the different transactions. The contracts are therefore interpreted in the same way by all the nodes, and it is, therefore, 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 money 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 an address by a script like:

DUP HASH160 <address> EQUALVERIFY CHECKSIG 

Nevertheless, Bitcoin’s virtual machine is not Turing-complete and is intentionally limited to procedural operations. For example, it is impossible to perform loops and practice recursion with the Script language. This is why Ethereum was created: to be a general-purpose, decentralized global computer that allows for the execution of an extreme variety of autonomous contracts.

The Ethereum virtual machine (Ethereum Virtual machine or EVM) has therefore been designed to be almost Turing-complete: it is possible to perform loops and recursions, but it is limited by a gas system so that only a contract cannot run endlessly and paralyze the network. It is based on a bytecode similar to the Bitcoin Script. However, most contracts are usually written in a higher-level language, compiled to bytecode, greatly facilitating the developer’s task. 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.

Bitcoin and Ethereum are not the only protocols to support smart contracts: almost all cryptocurrency systems have programming capabilities, except for a few systems like Monero. Here is a list of some strings with their respective languages:

blockchainMachine language (interpreted)Developer language (converted/compiled)
BitcoinScriptMiniscript, Policy
bitcoin-cashScript (modified)CashScript, Spedn
EthereumEVM bytecodeSolidity, Vyper
TezosMichelsonLiquidity, LIGO, SmartPy, Archetype
CardanoIELE bytecodePlutus, Marlowe

What is the use of smart contracts?

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

Here are some examples of smart contract applications:

  • Multi-signature accounts: these allow the setting up joint accounts requiring several signatures to carry out transfers.
  • The fiduciary deposit (escrow payment in English) allows the sequestration of funds pending the deferred shipment of a good. This type of contract is, for example, implemented by the peer-to-peer buying/selling platform LocalCryptos.
  • Payment channels give two users the ability to make micropayments to each other. It is on these channels that the Lightning Network is based.
  • The representation of assets on a blockchain by a token (or token): this is called tokenization. This can concern fungible goods (such as stablecoins which are backed by fiat currencies), as well as non-fungible goods (such as real estate with RealT).
  • Fundraising, which mostly relies on the pre-sale of a digital token with future utility. We talk about Initial Coin Offering (ICO), Initial Exchange Offering (IEO) or Security Token Offering (STO) depending on the context and the nature of the token.
  • Decentralized crypto-asset exchanges. This can be cryptocurrencies on different chains (via atomic swaps ) or cryptos on the same chain (Uniswap, Kyber Network, Binance DEX, etc.)
  • Decentralized lending, with Maker and Compound.
  • 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.

There are also many other use cases that have yet to be fully exploited. We can cite:

  • The notarial profession allows the automation of processes such as birth certificates, property transfers, etc.
  • Insurance:  driving in clear weather and on an open road would give different compensation than driving at night on a bumpy road.
  • The logistics chain (supply chain): according to the orders of its customers, a company would automatically order the number of parts necessary for the realization of such or such product.

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

What are the risks?

As with anything in computing, the main risk with smart contracts is the risk of hacking.

Since the code is published on the channel, it is possible for a hacker to identify its weaknesses and exploit them. This has already happened many times on Ethereum, for extremely high amounts: the best-known case is the TheDAO contract hack on June 17, 2016, which allowed someone to seize 3.6 million ethers or over $150 million at the time. This case led to the split between Ethereum (ETH) and Ethereum Classic (ETC): Ethereum indeed chose to cancel the transfer to reimburse TheDAO investors. At the same time, Ethereum Classic preferred to follow the principle of immutability.

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

  • The use of standards 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 with specialized firms.

What is the Legal Value for Smart Contracts?

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

Smart contracts currently have no legal value. If somehow your contract funds get siphoned off by a hacker, there is no recourse possible as this is not considered theft.

Nevertheless, it is possible that in the future (and with the maturation of the various crypto-economic protocols), legal systems will recognize the validity of information located on certain chains. In reality, the idea is not to adapt the various blockchains to the existing legal system but to eventually base the entire legal system on these blockchains.

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