-2.8 C
New York
Thursday, December 26, 2024

What is a smart contract or intelligent contract?

A smart contract, translated into French by intelligent 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 as in French. A chip card is a smart card, and we talk about smart city 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 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. programmable .

The real revolution came in 2015 with the launch of Ethereum , which allowed the construction of more complex autonomous contracts , in particular by using a specific programming language called Solidity. The latter allows 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, 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.

For example, a lottery can be implemented through a smart contract: a person deploys the contract at 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 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.

Note in passing that smart contracts form the basis of what are called decentralized applications or DApps .

What 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:

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 what Ethereum was created for: to be a general-purpose, decentralized global computer that allows an extreme variety of autonomous contracts to be executed.

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, which is compiled to bytecode , which greatly facilitates 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.

Here is a simple example of a contract written in Solidity (example taken from Mastering Ethereum ). It is a โ€œfaucetโ€ system that gives ethers (ETH) for free to whoever requests it in the contract:

pragma solidity ^0.4.19;

Contract Faucet

{

// Function giving ETH

function withdraw(uint withdraw_amount) public

{

// Withdrawal amount limited to 0.1 ETH

require(withdraw_amount <= 100000000000000000);

// Send the amount to the address that requested it

msg.sender.transfer(withdraw_amount);

}

// Contract accepts incoming payments (bailout)

function () public payable {}

}

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 of joint accounts requiring several signatures to carry out transfers.
  • The fiduciary deposit ( escrow payment in English), allowing 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 , which 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 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 .

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

  • The notarial profession , allowing 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, and this 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, while 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 do not has not programmed for. 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 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 different blockchains to the existing legal system, but to eventually base the entire legal system on these blockchains .

Moreover, even if blockchain governance systems 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 significant enough to reverse the process.

Stella Mason
Stella Mason
Stella Mason is a artist and blockchain enthusiast. She got in touch with crypto in 2016, but the fire really lit in 2017. Professionally she's a content optimization expert and worked for press agencies and video production companies, always with a focus on the video games & tech industry.

Latest Posts

Don't Miss

Stay in touch

To be updated with all the latest news, offers and special announcements.