News
What are smart contracts on the Blockchain and how do they work?
What is a smart contract?
A smart contract is a self-executing program that automates the actions required in a blockchain transaction. Once completed, transactions are traceable and irreversible. The best way to imagine a smart contract is to think of a vending machine: when you enter the correct amount of money and press an item button, the program (the smart contract) activates the machine to dispense the chosen item.
Smart contracts enable trustworthy transactions and agreements between disparate, anonymous parties without the need for a central authority, legal system, or external enforcement mechanism.
Although blockchain technology has primarily been regarded as the foundation of Bitcoin, it has evolved far beyond supporting a virtual currency.
What you need to know
- Smart contracts are scripts that automate actions between two parties.
- Smart contracts contain no legal language, terms, or agreements, just code that performs actions when specific conditions are met.
- Nick Szabo, an American computer scientist who conceptualized a virtual currency called “Bit Gold” in 1998, defined smart contracts as computerized transaction protocols that execute the terms of a contract.
- “Smart contract” is somewhat of a misnomer: these programs are neither smart nor a contract.
Investopedia / Laura Porter
History of smart contracts
Smart contracts were first proposed in 1994 by Nick Szabo, an American computer scientist who conceptualized a virtual currency called “Bit Gold” in 1998, 10 years before the introduction of Bitcoin. Szabo is often said to be the real Satoshi Nakamoto, the anonymous inventor of Bitcoin, which he has denied.
Szabo defined smart contracts as computerized transaction protocols that execute the terms of a contract. He wanted to extend the functionality of electronic transaction methods, such as POS (point of sale), to the digital realm.
In his article Szabo also proposed contracting for synthetic assets, such as combining derivatives and bonds. Szabo wrote: “These new securities are formed by combining securities (such as bonds) and derivatives (options and futures) in a wide variety of ways. Very complex term structures for payments… can now be integrated into contracts standardized and exchanged with low transaction costs, thanks to computer analysis of these complex term structures.”
Smart contracts do not contain the legal language or even the terms of a contract between two parties. They are scripts that contain functions, module imports, and other programming that automates actions between two parties.
Many of Szabo’s predictions in the paper came true in ways that predate blockchain technology. For example, derivatives trading is now conducted primarily through computer networks that use complex terminological structures.
Uses of the smart contract
Because smart contracts execute agreements, they can be used for many different purposes. One of the simplest uses is to ensure that transactions occur between two parties, such as the purchase and delivery of goods. For example, a manufacturer that needs raw materials can set up payments using smart contracts, and the supplier can set up shipments. Then, depending on the agreement between the two companies, the funds may be automatically transferred to the supplier upon shipment or delivery.
It is important to understand that the connections between blockchain transactions and real-world transfers are still developing. For example, if you use ether to order an item from a retailer that uses an e-commerce blockchain that can communicate with Ethereum, it still needs to be packaged and shipped by a person. In this case, a smart contract would likely transfer your cryptocurrency to the retailer and launch another script that notifies the shipping department of a sale.
Real estate transactions, stock and commodity trading, lending, corporate governance, supply chain, dispute resolution, and healthcare are just a few examples where smart contracts are theorized to be used.
Pros and cons of the smart contract
The main advantage of smart contracts is similar to the advantage of blockchain technology: they eliminate the need for third parties. Other advantages of this technology are:
- Efficiency: They speed up the execution of the contract
- Precision: No human error may be introduced
- Immutability: Programming cannot be changed
Some of the disadvantages of smart contracts are:
- Permanent: Cannot be edited if there are errors
- Human factor: They rely on the programmer to ensure that the code is programmed correctly to perform its intended actions
- Gaps: There may be gaps in the coding, allowing contracts to be enforced in bad faith
What is an example of a smart contract?
The simplest example of a smart contract is a transaction between a consumer and a company, in which a sale is made. The smart contract could execute the customer’s payment and initiate the company’s shipping process.
What is the purpose of a Smart Contract?
The purpose of smart contracts is to further eliminate the need for a trusted third party to conduct actions between parties who do not trust each other.
What are the four main parts of a Smart Contract?
It depends on the blockchain and how it is programmed. In general, smart contracts have state variables (data), functions (what can be done), events (incoming and outgoing messages), and modifiers (special rules for specific users). Some may have additional elements depending on the purpose they are designed for.
The bottom line
Smart contracts are codes written in a blockchain that execute actions agreed upon by two parties outside the chain. By automating these actions, the need for an intermediary or trust between parties is eliminated.