You get a bonus - 1 coin for daily activity. Now you have 1 coin

Smart Contract - a Computer Algorithm

Lecture



Smart contract (Smart contract) — a computer algorithm designed to form, control, and provide information about the ownership of something. Most often this refers to the use of blockchain technology. In a narrower sense, a smart contract is understood as a set of functions and data (current state) located at a specific address on the blockchain .

A smart contract is a computer program or transaction protocol intended to automatically execute, control, or document legally significant events and actions in accordance with the terms of a contract or agreement. The goals of smart contracts are to reduce the need for trusted intermediaries, arbitration proceedings and enforcement costs, losses from fraud, and to reduce the number of malicious and accidental exceptions.

Smart contracts — are computer programs that formulate the rules for making entries, i.e. «transactions», in the blockchain.

The first country to legislatively establish smart contracts was Belarus.

Ethereum smart contracts are developed in one of the languages designed for translation into the bytecode of the Ethereum virtual machine — Solidity (similar to C or JavaScript), Vyper and Serpent (similar to Python), LLL (a low-level version of Lisp), Mutan (based on Go)

Example of a smart contract for BNB

Smart Contract - a Computer Algorithm https://etherscan.io/address/0xB8c77482e45F1F44dE1745F52C74426C631bDD52#code

How it works

The parties sign a smart contract using methods similar to signing the sending of funds in existing cryptocurrency networks. After the parties sign, the contract is stored on the blockchain and comes into effect. To ensure automated execution of the contract's obligations, an execution environment is necessarily required (nodes of the Ethereum blockchain), which allows the contract's clauses to be executed fully automatically. This means that smart contracts can exist only within an environment that provides unimpeded access of executable code to the smart contract's objects.

All the terms of the contract must have a programmatic description and clear execution logic. In this regard, the first smart contracts have the task of formalizing the simplest relationships, consisting of a small number of conditions. Having unimpeded access to the contract's objects, a smart contract tracks the achievement or violation of clauses according to the specified conditions and makes independent decisions based on the programmed conditions. Thus, the basic principle of a smart contract consists in the full automation and reliability of the execution of contractual relations.

History

The first ideas for smart contracts were proposed by Nick Szabo . Practical implementations became possible thanks to the appearance of blockchain technology in 2008 . Some principles of smart contracts were already laid down in the very first Bitcoin protocol; however, they were not implemented in client software, did not have Turing completeness for security reasons, and were not widely used in practice. With the advent of the technology, ideas began to be expressed that various higher-level protocols, including full-fledged smart contracts , could be built on top of the Bitcoin protocol, by analogy with how numerous application-layer protocols exist on top of TCP/IP.

Smart contracts first gained widespread use with the appearance of Ethereum. The idea for the project arose in 2013. At that moment, Bitcoin Magazine founder Vitalik Buterin came to the conclusion that blockchain technology could be used much more broadly, not only in cryptocurrencies. He put forward the idea of a universal decentralized blockchain platform in which anyone could programmatically implement various systems for storing and processing information. The main condition — actions must be described as mathematical rules .

Objects of a smart contract

  • Signatories — the parties to a smart contract, accepting or rejecting the terms using electronic signatures. A direct analog is the signature of the sender of funds in the Bitcoin network, which confirms the inclusion of the transaction in the blockchain.
  • Subject of the agreement. The subject of the agreement can only be an object located within the environment of existence of the smart contract itself, or the smart contract must be provided with unimpeded, direct access to the subject of the agreement without human involvement.
  • Terms. The terms of a smart contract must have a complete mathematical description that can be programmed within the smart contract's environment of existence. It is precisely in the terms that the execution logic of the clauses of the subject of the agreement is described.
  • Decentralized platform. Distributed storage of the smart contract requires it to be recorded on this platform's blockchain.

How it works

Similar to the transfer of value on the blockchain, the deployment of a smart contract on the blockchain occurs by sending a transaction from a wallet to the blockchain. The transaction includes the compiled code for the smart contract, as well as a special recipient address. This transaction must then be included in a block, which is added to the blockchain, after which the smart contract's code will execute to establish the smart contract's initial state. [32] Byzantine fault-tolerant algorithms protect the smart contract from hacking attempts in a decentralized manner. Once a smart contract has been deployed, it cannot be updated. Smart contracts on the blockchain can store arbitrary state and perform arbitrary computations. End clients interact with a smart contract through transactions. Such transactions with a smart contract can invoke other smart contracts. These transactions can result in a change of state and the sending of coins from one smart contract to another, or from one account to another.

The most popular blockchain for running smart contracts is Ethereum. On Ethereum, smart contracts are typically written in a Turing-complete programming language called Solidity, and are compiled into low-level bytecode that is executed by the Ethereum virtual machine. [36] Because of the halting problem and other security issues, Turing completeness is considered a risk, and languages such as Vyper deliberately avoid it. Some of the other smart-contract programming languages that lack Turing completeness are Simplicity, Scilla, Ivy, and Bitcoin Script. [38] However, measurements using regular expressions showed that only Smart Contract - a Computer Algorithm% of Smart Contract - a Computer Algorithm Ethereum smart contracts included recursion and loops — constructs associated with the halting problem.

Several languages are designed to enable formal verification: Bamboo, IELE, Simplicity, Michelson (can be verified using Coq), Liquidity (compiles to Michelson), Scilla, DAML, and Pact.

Notable examples of blockchain platforms supporting smart contracts include the following:
Name Description
Bitcoin Provides a non-Turing-complete scripting language that allows custom smart contracts to be created on top of Bitcoin, such as multi-signature accounts, payment channels, escrow, timelocks, atomic cross-chain trading, oracles, or an operator-free multiparty lottery.
Cardano A blockchain platform for smart contracts using proof of stake
Codius Open-sourced by Ripple in 2014, but shelved in 2015
Ethereum Implements a Turing-complete language on its blockchain, a well-known smart contract framework
EOS.IO A blockchain platform for smart contracts
Tezos A blockchain platform that changes its own rule set with minimal disruption to the network's operation through an on-chain governance model.

Processes in a blockchain are, as a rule, deterministic in order to ensure Byzantine fault tolerance. Nevertheless, the use of smart contracts in the real world, for example lotteries and casinos, requires secure randomness. [44] In fact, blockchain technology reduces the cost of running a lottery and is therefore advantageous for participants. Randomness in a blockchain can be implemented using block hashes or timestamps, oracles, commitment schemes, special smart contracts such as RANDAO and Quanta, and sequences derived from mixed-strategy Nash equilibria.

Replication of registries and execution of contracts

In 1998 Szabo proposed that the infrastructure for smart contracts could be implemented by replicating asset registries and executing contracts using cryptographic hash chains and Byzantine fault-tolerant replication. [47] Askemos implemented this approach in 2002, using Scheme (later adding SQLite) as the contract scripting language.

One proposal for using bitcoins to register replicated assets and execute contracts is called "colored coins." Replication of ownership rights to potentially arbitrary forms of property, together with replication of contract execution, has been implemented in various projects.

In 2015, UBS experimented with "smart" bonds that use the Bitcoin blockchain [54], in which payment streams could hypothetically be fully automated, creating a self-paying instrument.

Security issues

A blockchain-based smart contract is visible to all users of the blockchain in question. However, this leads to a situation in which errors, including security holes, are visible to everyone but cannot be quickly fixed. Such an attack, difficult to fix quickly, was successfully carried out against The DAO in June 2016, draining approximately US $50 million worth of Ether at the time, while the developers tried to arrive at a solution that would achieve consensus. The DAO program had a time delay before the hacker could withdraw the funds; a hard fork of the Ethereum software was carried out to take the funds back from the attacker before the deadline expired. [58] Other high-profile attacks include attacks on the Parity multi-signature wallet and the integer overflow/underflow attack (2018), totaling more than $184 million.

Problems in Ethereum smart contracts, in particular, include ambiguity and simple but insecure constructs in the Solidity contract language, compiler bugs, bugs in the Ethereum virtual machine, attacks on the blockchain network, the immutability of bugs, and the lack of documentation from a central source of known vulnerabilities, attacks, and problematic constructs. [

Difference from smart legal contracts

Smart legal contracts differ from smart contracts. As mentioned above, a smart contract does not necessarily have legal force as a contract. On the other hand, a smart legal contract has all the elements of a legally enforceable contract in the jurisdiction in which it can be enforced, and it can be enforced by a court or tribunal. Consequently, although every smart legal contract will contain some elements of a smart contract, not every smart contract will be a smart legal contract.

There is no formal definition of a smart legal contract in the legal industry.

A Ricardian contract is a type of smart legal contract.

Environment for smart contracts to operate

In order for smart contracts to exist, certain conditions are required:

  1. The use of widely adopted electronic signature methods based on public and private keys (asymmetric encryption).
  2. The existence of open, decentralized databases, trusted by the parties to the contract, for executable transactions, whose operation completely excludes the human factor. As an example: the blockchain in Bitcoin.
  3. Decentralization of the smart contract execution environment. As an example: Ethereum, Codius, Counterparty
  4. Trustworthiness of the source of digital data. As an example: SSL root certification authorities in the databases of modern internet browsers.

Example

  • By analogy with an IPO, an initial blockchain offering is introduced (ICO, from the English "initial coin offerings") — a crowdfunding method for organizing startups. Based on a published memorandum, investors send funds to the account of the corresponding smart contract, receiving in return monetary tokens that play the role of shares of the given startup. As of August 2017, the volume of investment in ICOs amounts to $550 million
  • Decentralized finance services (DeFi) — non-custodial protocols for lending against collateral in digital assets, and platforms for trading tokens and derivatives
  • A decentralized autonomous organization — a mechanism for coordinating the activity of a group of people to achieve common goals, the rules of operation of which can be set in the form of smart contracts.
  • There is an idea of creating a decentralized, Ethereum-based product similar to Facebook, where users would gain full control over their personal pages, giving them the ability to earn advertising revenue themselves, instead of some company.
  • In October 2018, the Central Bank of the Russian Federation prepared an analytical review on the topic of "Smart Contracts." This review presents areas of application of smart contracts, as well as specific examples of the implementation of smart contracts in the financial market.
  • The possibility of creating a securities market without the participation of a stock exchange or a clearing center. Carrying out agreements would require neither the services of lawyers nor platforms protected from unauthorized access for voting or polling, without the need to count votes, without processing of ballots by an electoral body, and without the participation of a sociological center.

The first large and promising area of blockchain development is the financial one. This includes cryptocurrency, smart contracts, and state registries. For example, right now, selling a house takes several weeks, whereas it could take just 3 minutes.

Vitalik Buterin, Moscow, August 30, 2017[15]

Prospects

Proponents of smart contracts argue[ that many types of them can be made partially or fully self-executing and self-sufficient. Smart contracts based on cryptography are capable of providing better security than traditional contracts based on law, and of reducing other transaction costs associated with concluding agreements and possible litigation costs.

According to the British magazine The Economist, smart contracts have the prospect of becoming the most important application of blockchain technology[12].

Smart contracts can acquire legal significance if they comply with the laws of a given state. For this, it is necessary that smart contracts contain the conditions and restrictions established by the state's legislation[16].

Belarus became the first country in the world to legislatively establish smart contracts on December 21, 2017, under the Decree on the Development of the Digital Economy. [17]The developer of the legal concept of the smart contract was the Belarusian lawyer Denis Aleinikov. The country plans to allow banks to conclude smart contracts.

Drawbacks

Observers express concern that the spread of automated contract-maintenance technologies could lead to the weakening of existing social institutions that humanity has built over many generations. In addition, such technologies could lead to the disappearance of a large number of administrative jobs, just as robotization led to the disappearance of jobs in industry[12]. This applies, in particular, to notaries, bank employees, and clerks dealing with the registration of real estate transactions.

Negligence on the part of developers can lead to malicious use of smart contracts, as shown by the story of the leak of more than three million Ether coins from The DAO project[23].

See also

  • [[b8782]]
  • [[b8300]]
  • [[b8133]]
  • [[b9306]]
  • [[b8475]]
  • [[b8718]]
  • Code and laws of cyberspace
  • Ethereum
  • Regulation by algorithms
  • Regulation of algorithms
  • [[b8784]]
  • Secure multi-party computation

See also

created: 2021-12-11
updated: 2026-03-08
146



Was this answer useful?
Choose a quick rating so we can improve the next answer for you.
How satisfied are you?


Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Algorithms"

Terms: Algorithms