A smart contract is a
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
or a
transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a
contract
A contract is an agreement that specifies certain legally enforceable rights and obligations pertaining to two or more parties. A contract typically involves consent to transfer of goods, services, money, or promise to transfer any of thos ...
or an agreement.
The objectives of smart contracts are the reduction of need for trusted intermediators, arbitration costs, and fraud losses, as well as the reduction of malicious and accidental exceptions.
[ Smart contracts are commonly associated with cryptocurrencies, and the smart contracts introduced by ]Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
are generally considered a fundamental building block for decentralized finance
Decentralized finance (often stylized as DeFi) provides financial instruments and services through smart contracts on a programmable, permissionless blockchain. This approach reduces the need for intermediaries such as brokerages, exchanges, or ...
(DeFi) and non-fungible token
A non-fungible token (NFT) is a unique digital identifier that is recorded on a blockchain and is used to certify ownership and authenticity. It cannot be copied, substituted, or subdivided. The ownership of an NFT is recorded in the blockchai ...
(NFT) applications.
The original Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
white paper
A white paper is a report or guide that informs readers concisely about a complex issue and presents the issuing body's philosophy on the matter. It is meant to help readers understand an issue, solve a problem, or make a decision. Since the 199 ...
by Vitalik Buterin
Vitaly Dmitrievich Buterin (; born 31 January 1994), better known as Vitalik Buterin (), is a Canadian computer programmer and co-founder of Ethereum. Buterin became involved with cryptocurrency early in its inception, co-founding ''Bitcoin Ma ...
in 2014 describes the Bitcoin protocol as a weak version of the smart contract concept as originally defined by Nick Szabo
Nicholas Szabo is an American computer scientist, legal scholar, and cryptographer known for his research in smart contracts and digital currency.
Personal life
Szabo currently resides in Seattle, Washington and is married to Michelle Szabo.
...
, and proposed a stronger version based on the Solidity language, which is Turing complete
Alan Mathison Turing (; 23 June 1912 – 7 June 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher and theoretical biologist. He was highly influential in the development of theoretical comput ...
. Since then, various cryptocurrencies have supported programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
s which allow for more advanced smart contracts between untrusted parties.
A smart contract should not be confused with a smart legal contract, which refers to a traditional, natural-language, legally-binding agreement that has selected terms expressed and implemented in machine-readable code.[
]
Etymology
By 1996, Nick Szabo
Nicholas Szabo is an American computer scientist, legal scholar, and cryptographer known for his research in smart contracts and digital currency.
Personal life
Szabo currently resides in Seattle, Washington and is married to Michelle Szabo.
...
was using the term "smart contract" to refer to contracts which would be enforced by physical property (such as hardware or software) instead of by law. Szabo described vending machine
A vending machine is an automated machine that dispenses items such as snacks, beverages, cigarettes, and lottery tickets to consumers after cash, a credit card, or other forms of payment are inserted into the machine or payment is otherwise m ...
s as an example of this concept. In 1998, the term was used to describe objects in rights management service layer of the system ''The Stanford Infobus'', which was a part of Stanford Digital Library Project.[
]
Legal status of smart contracts
A ''smart contract'' does not typically constitute a valid binding agreement at law.[ Proposals exist to regulate smart contracts.]
Smart contracts are not legal agreements, but instead transactions which are executed automatically by a computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
or a transaction protocol,[Mik, Eliza, Smart Contracts: A Requiem (December 7, 2019). Journal of Contract Law (2019) Volume 36 Part 1 at p 72] such as technological means for the automation of payment obligations such as by transferring cryptocurrencies or other tokens. Some scholars have argued that the imperative or declarative nature of programming languages would impact the legal validity of smart contracts.
In some jurisdictions, legal scholars have examined how the rigidity of smart contracts interacts with traditional doctrines such as contractual unforeseeability. For instance, Colombian legal scholarship has proposed adapting the theory of supervening onerousness (teoría de la imprevisión) to account for the high economic and systemic costs of reversing smart contract effects through judicial intervention, emphasizing the need to internalize these costs and develop new procedural mechanisms for digital environments.
Since the 2015 launch of the Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
blockchain
The blockchain is a distributed ledger with growing lists of Record (computer science), records (''blocks'') that are securely linked together via Cryptographic hash function, cryptographic hashes. Each block contains a cryptographic hash of th ...
, the term "smart contract" has been applied to general purpose computation that takes place on a blockchain. The US National Institute of Standards and Technology describes a "smart contract" as a "collection of code and data (sometimes referred to as functions and state) that is deployed using cryptographically signed transactions on the blockchain network". In this interpretation a smart contract is any kind of computer program which uses a blockchain. A smart contract also can be regarded as a secured stored procedure
A stored procedure (also termed prc, proc, storp, sproc, StoPro, StoredProc, StoreProc, sp, or SP) is a subroutine available to applications that access a relational database management system (RDBMS). Such procedures are stored in the database d ...
, as its execution and codified effects (like the transfer of tokens between parties) cannot be manipulated without modifying the blockchain itself. In this interpretation, the execution of contracts is controlled and audited by the platform, not by arbitrary server-side programs connecting to the platform.
In 2018, a US Senate
The United States Senate is a chamber of the bicameral United States Congress; it is the upper house, with the U.S. House of Representatives being the lower house. Together, the Senate and House have the authority under Article One of the ...
report said: "While smart contracts might sound new, the concept is rooted in basic contract law. Usually, the judicial system adjudicates contractual disputes and enforces terms, but it is also common to have another arbitration method, especially for international transactions. With smart contracts, a program enforces the contract built into the code."[Chapter 9: Building a Secure Future, One blockchain at a time]
, US Senate
The United States Senate is a chamber of the bicameral United States Congress; it is the upper house, with the U.S. House of Representatives being the lower house. Together, the Senate and House have the authority under Article One of the ...
Joint Economic Committee, March 2018. States in the US which have passed legislation on the use of smart contracts include Arizona, Iowa, Nevada, Tennessee, and Wyoming.
In April 2021, the UK Jurisdiction Taskforce (UKJT) published the Digital Dispute Resolution Rules (the Digital DR Rules), which were intended to enable the rapid resolution of blockchain and crypto legal disputes in Britain.
Workings
Similar to a transfer of value on a blockchain, deployment of a smart contract on a blockchain occurs by sending a transaction from a wallet
A wallet is a flat case or pouch, often used to carry small personal items such as physical currency, debit cards, and credit cards; identification documents such as driving licence, identification card, club card; photographs, transit pass, b ...
for the blockchain. The transaction includes the compiled code for the smart contract as well as a special receiver address.[ That transaction must then be included in a block that is added to the blockchain, at which point the smart contract's code will execute to establish the initial state of the smart contract.][ Byzantine fault-tolerant algorithms secure the smart contract in a decentralized way from attempts to tamper with it. Once a smart contract is deployed, it cannot be updated.] Smart contracts on a blockchain can store arbitrary state and execute arbitrary computations. End clients interact with a smart contract through transactions. Such transactions with a smart contract can invoke other smart contracts. These transactions might result in changing the state and sending coins from one smart contract to another or from one account to another.[
The most popular blockchain for running smart contracts is ]Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
. On Ethereum, smart contracts are typically written in a Turing-complete
In computability theory, a system of data-manipulation rules (such as a model of computation, a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be ...
programming language called Solidity, and compiled into low-level bytecode
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
to be executed by the Ethereum Virtual Machine. Due to the halting problem
In computability theory (computer science), computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run for ...
and other security problems, Turing-completeness is considered to be a risk and is deliberately avoided by languages like Vyper. Some of the other smart contract programming languages missing Turing-completeness are Simplicity, Scilla, Ivy and Bitcoin Script.[ However, measurements in 2020 using ]regular expression
A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s showed that only 35.3% of 53,757 Ethereum smart contracts at that time included recursions and loops — constructs connected to the halting problem.
Several languages are designed to enable formal verification
In the context of hardware and software systems, formal verification is the act of proving or disproving the correctness of a system with respect to a certain formal specification or property, using formal methods of mathematics.
Formal ver ...
: Bamboo, IELE, Simplicity, Michelson (can be verified with Coq
Coenzyme Q10 (CoQ10 ), also known as ubiquinone, is a naturally occurring biochemical cofactor (coenzyme) and an antioxidant produced by the human body. It can also be obtained from dietary sources, such as meat, fish, seed oils, vegetables, ...
), Liquidity (compiles to Michelson), Scilla, DAML and Pact.
Processes on a blockchain are generally deterministic in order to ensure Byzantine fault tolerance
A Byzantine fault is a condition of a system, particularly a distributed computing system, where a fault occurs such that different symptoms are presented to different observers, including imperfect information on whether a system component has fa ...
. Nevertheless, real world application of smart contracts, such as lotteries
A lottery (or lotto) is a form of gambling that involves the drawing of numbers at random for a prize. Some governments outlaw lotteries, while others endorse it to the extent of organizing a national or state lottery. It is common to find som ...
and casino
A casino is a facility for gambling. Casinos are often built near or combined with hotels, resorts, restaurants, retail shops, cruise ships, and other tourist attractions. Some casinos also host live entertainment, such as stand-up comedy, conce ...
s, require secure randomness. In fact, blockchain technology reduces the costs for conducting of a lottery and is therefore beneficial for the participants. Randomness on blockchain can be implemented by using block hashes or timestamps, oracles, commitment schemes, special smart contracts like RANDAO and Quanta, as well as sequences from mixed strategy Nash equilibria
In game theory, the Nash equilibrium is the most commonly used solution concept for non-cooperative games. A Nash equilibrium is a situation where no player could gain by changing their own strategy (holding all other players' strategies fixed) ...
.[
]
Applications
In 1998, Szabo proposed that smart contract infrastructure can be implemented by replicated asset registries and contract execution using cryptographic hash chains and Byzantine fault-tolerant replication. Askemos implemented this approach in 2002 using Scheme (later adding SQLite
SQLite ( "S-Q-L-ite", "sequel-ite") is a free and open-source relational database engine written in the C programming language. It is not a standalone app; rather, it is a library that software developers embed in their apps. As such, it ...
) as the contract script language.
One proposal for using Bitcoin for replicated asset registration and contract execution is called " colored coins". Replicated titles for potentially arbitrary forms of property, along with replicated contract execution, are implemented in different projects.
, UBS was experimenting with "smart bonds" that use the bitcoin
Bitcoin (abbreviation: BTC; Currency symbol, sign: ₿) is the first Decentralized application, decentralized cryptocurrency. Based on a free-market ideology, bitcoin was invented in 2008 when an unknown entity published a white paper under ...
blockchain
The blockchain is a distributed ledger with growing lists of Record (computer science), records (''blocks'') that are securely linked together via Cryptographic hash function, cryptographic hashes. Each block contains a cryptographic hash of th ...
in which payment streams could hypothetically be fully automated, creating a self-paying instrument.
Inheritance
Inheritance is the practice of receiving private property, titles, debts, entitlements, privileges, rights, and obligations upon the death of an individual. The rules of inheritance differ among societies and have changed over time. Offi ...
wishes could hypothetically be implemented automatically upon registration of a death certificate
A death certificate is either a legal document issued by a medical practitioner which states when a person died, or a document issued by a government civil registration office, that declares the date, location and cause of a person's death, a ...
by means of smart contracts. Birth certificate
A birth certificate is a vital record that documents the Childbirth, birth of a person. The term "birth certificate" can refer to either the original document certifying the circumstances of the birth or to a certified copy of or representation ...
s can also work together with smart contracts.
Chris Snook of '' Inc.com'' suggests smart contracts could also be used to handle real estate transactions and could be used in the field of title records and in the public register.
Seth Oranburg and Liya Palagashvili argue that smart contracts could also be used in employment contract
An employment contract or contract of employment is a kind of contract used in labour law to attribute rights and responsibilities between parties to a bargain.
The contract is between an "employee" and an "employer". It has arisen out of the old m ...
s, especially temporary employment contracts, which according to them would benefit the employer.
Security issues
The transactions data from a blockchain-based smart contract is visible to all users in the blockchain. The data provides cryptographic view of the transactions, however, this leads to a situation where bugs, including security holes, are visible to all yet may not be quickly fixed. Such an attack, difficult to fix quickly, was successfully executed on The DAO in June 2016, draining approximately million worth of Ether
In organic chemistry, ethers are a class of compounds that contain an ether group, a single oxygen atom bonded to two separate carbon atoms, each part of an organyl group (e.g., alkyl or aryl). They have the general formula , where R and R� ...
at the time, while developers attempted to come to a solution that would gain consensus. The DAO program had a time delay in place before the hacker could remove the funds; a hard fork of the Ethereum software was done to claw back the funds from the attacker before the time limit expired. Other high-profile attacks include the Parity multisignature wallet attacks, and an integer underflow/overflow attack (2018), totaling over million.
Issues in Ethereum smart contracts, in particular, include ambiguities and easy-but-insecure constructs in its contract language Solidity, compiler bugs, Ethereum Virtual Machine bugs, attacks on the blockchain network, the immutability of bugs and that there is no central source documenting known vulnerabilities, attacks and problematic constructs.
Difference from smart legal contracts
Smart legal contracts are distinct from smart contracts. As mentioned above, a smart contract is not necessarily legally enforceable 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. Therefore, while 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.Whitepaper: Smart Contracts and Distributed Ledger – A Legal Perspective
, 3.
A Ricardian contract is a type of smart legal contract.
See also
* '' Code and Other Laws of Cyberspace''
* Decentralized application
A decentralised application (DApp, dApp, Dapp, or dapp) is an Application software, application that can operate autonomously, typically through the use of smart contracts, that run on a decentralized computing, blockchain or other distributed le ...
* Ethereum
Ethereum is a decentralized blockchain with smart contract functionality. Ether (abbreviation: ETH) is the native cryptocurrency of the platform. Among cryptocurrencies, ether is second only to bitcoin in market capitalization. It is open-s ...
* Regulation by algorithms
Government by algorithm (also known as algorithmic regulation, regulation by algorithms, algorithmic governance, algocratic governance, algorithmic legal order or algocracy) is an alternative form of government or social ordering where the usag ...
* Regulation of algorithms
Regulation of algorithms, or algorithmic regulation, is the creation of laws, rules and public sector policies for promotion and regulation of algorithms, particularly in artificial intelligence and machine learning. For the subset of AI algorith ...
* Ricardian contract (a design pattern to capture the intent of the agreement of parties)
* Loan
In finance, a loan is the tender of money by one party to another with an agreement to pay it back. The recipient, or borrower, incurs a debt and is usually required to pay interest for the use of the money.
The document evidencing the deb ...
* Secure multiparty computation
Secure multi-party computation (also known as secure computation, multi-party computation (MPC) or privacy-preserving computation) is a subfield of cryptography with the goal of creating methods for parties to jointly compute a function over their ...
* Transparency
References
{{Authority control
Blockchains
Computer law
Contract law
Cryptocurrencies