In 2008, a man under the pseudonym Satoshi Nakamoto made public the concept of virtual digital currency Bitcoin. It would seem what could be even more surprising than money working in a virtual environment, not issued and not managed by one person or company?
However, as it became clear a little later, the world of blockchain became even more interesting and full-fledged with the advent of smart contracts. In theory, smart contracts should replace the services of sellers, bankers, notaries, judges and more. But how are things really and can smart contracts do what is expected of them? Today we will deal with this.
- What is a Smart Contract?
- The History of the Emergence and Development of Smart Contracts
- Objects of Smart Contracts and Working Conditions
- How do Smart Contracts Work
- Ethereum Smart Contracts
- Smart Contract Platforms
- Differences Between Smart Contracts and Ordinary Contracts
- Advantages and Disadvantages of Smart Contracts
- Areas of Use of Smart Contract
What is a Smart Contract?
A smart contract is a computer algorithm that is used to implement self-executing contracts in a blockchain environment. A smart "contract is governed by mathematical rules and executed in accordance with the prescribed conditions in the format" if ... .to. " The information entered is not subject to change or deletion.
The creator of the first Ethereum smart contract execution platform, Vitalik Buterin, describes how smart contracts work:
“The asset is entered into the program, and it itself monitors the fulfillment of the terms of the contract”
The History of the Emergence and Development of Smart Contracts
In 1994, Nick Szabo, an American developer and scientist in computer science suggested using software algorithms to conclude direct contracts between a buyer and a seller in the field of electronic commerce. And in 1998 he put his ideas into work under the name “Bitgold”. However, in practice, the work of smart contracts at that time could not be implemented, since there was no main one — the environment for their functioning, i.e. blockchain.
This was first made possible in 2008, when Satoshi Nakamoto introduced his Bitcoin project. Few people know that Bitcoin has the ability to implement smart contracts. However, this function is poorly developed, since bitcoin, first of all, is a payment system.
The latter fact pushed the young but very ambitious developer Vitalik Buterin in 2013, creates “from scratch” a unique platform that would be as convenient as possible for the implementation of smart contracts. So the Ethereum cryptocurrency was born. And then EOS, NEO cryptocurrency, Cardano cryptocurrency and other blockchain projects began to use this idea.
Objects of Smart Contracts and Working Conditions
Any smart contract must have the following attributes:
- Signatories — parties to a smart contract (at least two participants) that participate in the process of signing a contract or rejecting the prescribed conditions by using digital signatures;
- Subject of the contract — the subject of a smart contract can only be an object located on the decentralized network itself or on other sources that the program can access without involving a person. It was the absence of this attribute that did not allow implementing smart contracts in 1998, since at that time the concept of blockchain as a virtual decentralized environment was not yet formed and developed;
- Terms of the contract — the conditions look like a mathematical description that must be programmed in the working environment of the smart contract itself. They are registered according to the “if ... .to” algorithm;
- Decentralized platform — data on each smart contract should be recorded and stored in a distributed registry.
Smart contracts can only be executed if certain conditions are created:
- The presence of a digital signature, the basis for which are public and private keys;
- Decentralized platform, which is served by independent nodes;
- Trusted source of digital data;
- Mathematically proven Turing completeness
How do Smart Contracts Work
The work of smart contracts can be compared to the work of a coffee vending machine — throw a coin and get your cup of coffee.This is faster and more reliable than if a person was selling coffee.
The scheme of work of “smart” ones is similar to the operation of an automaton with the difference that they are executed in a virtual environment:
- User A creates a transaction (transaction), the code of which says that user B will receive a set of sweets if he sends user 10 coins.
- The transaction is sent to the decentralized network that the nodes serve. After she confirmed participants' smart contract, it can not be edited or deleted.
- After fulfilling the terms of the contract by user B (transfer to user A 10 coins) A box with sweets arrives to user B, while user A has not yet received payment for the goods, it is in a “frozen” state.
- If the nodes do not confirm the transfer of 10 coins by user B, then the box with sweets will not come to him and, moreover, he will have to be punished if it is prescribed in the terms of a smart contract. The same sanctions can be applied to user A, if, for example, he sends the wrong sweets that were prescribed in the contract.
- All information about a successful / unsuccessful transaction is recorded in a distributed registry.
In this case, human participation is not required at all. Unlike ordinary contracts, smart contracts not only store all information about the transaction, including information about the penalty in case of non-fulfillment of the terms by the parties, but also monitor the fulfillment of the terms themselves.
Even better to understand how smart contracts work, you can watch the video:
Ethereum Smart Contracts
An Ethereum smart contract is a set of data and functions associated with a specific address. With ordinary contracts, these objects are similar to the presence of predefined conditions and the corresponding response actions. But, in fact, the Ethereum smart contract is just a code programmed in the Solidity language, the fact of the execution of which is recorded in the blockchain.
It is activated using a transaction, which can contain both a regular coin transfer and a more complex team. The smart contract is executed within the framework of the Ethereum virtual machine (EVM), which provides the conditions for the transaction and protection from outside interference.
In the Ethereum blockchain, both types of accounts (smart contracts and regular accounts) can accept transactions. And since technically these are the same blockchain operations so that there is no confusion, generally accepted notations are conventionally applied to them:
- Transferring coins between wallets is called transfers;
- Transactions that activate smart contracts are messaging.
Any participant in the network who has enough balance to pay for this operation (up to 0.3 ETH) can create “Ethereum smart contracts”. To do this, a transaction is sent to the blockchain without specifying the addressee, but always with a commission and a compiled code for the future contract.
A fee is also charged for sending a message to the Ethereum smart contract and calling the function recorded in it. If the transaction indicated a too low commission, the implementation of the smart contract will be canceled.
The main area of use of Ethereum smart contracts is the organization of the work of thousands of dApps, as well as fundraising within the framework of ICO blockchain projects.
So, for example, the smart contract code looks like with the help of which the initial offer of EasyCoin conditional tokens is carried out with the start of the 90-day sale on October 10, 2019 (date in UNIX format):
It is based on a token issuing team for a user who sends a certain amount of ETH to the contract address if this event occurs within the campaign period. The resulting airtime is credited to the account of the owner of the contract.
As you can see, for such a seemingly complicated process of organizing crowdfunding, only a few lines of simple code implemented in the form of a smart contract are responsible.
Smart Contract Platforms
Now there are several dozen blockchain platforms for creating smart contracts, some of which offer similar opportunities. But there are also projects with original functionality, thanks to which they have gained popularity and recognition in the crypto community.
The first and by far the most used blockchain platform that fully supports the ability to create smart contracts. Thanks to the flexibility of the system and the use of the Turing-complete programming language Solidity, you can create smart contracts of any complexity.
The bandwidth required for the operation of all dApps Ethereum-based smart contracts is provided by the equipment of a huge number of network participants.
The main feature of Ethereum smart contracts is the need to pay in the form of gas both for their creation and interaction with them (a kind of protection against spam attacks), which makes using decentralized applications a rather expensive pleasure for end users.
Today it is the second platform for smart contracts in terms of the number of dApps created and the first in terms of the number of active requests to them. Launched in 2018 by Block.one. The main advantages are high bandwidth, scalability, parallel computing, support for the familiar C ++ language for many programmers, and the absence of fees for application users.
But for developers, EOS smart contracts are expensive because they are required to buy computing resources from the system — network traffic (NET), processor power (CPU) and random access memory (RAM). They are spent on deploying contracts and creating new user accounts that interact with them.
The platform, basically based on the Ethereum blockchain, but significantly improved, in particular in the field of development and use of smart contracts. Launched in 2017 by Chinese blockchain entrepreneur Justin Sun.
As with Ethereum, smart contracts are written in Solidity, and they are executed in a virtual machine (TVM).
An important feature is the ability to transfer existing dApps from the Ethereum network to the TRON platform.
The smart contracts themselves on this platform are called chaincode and can be used to create multi-level network configurations with four basic functions — the generation, return or removal of an asset, as well as access to the history of its changes.
The platform is characterized by the presence of enhancing the security of private channels and high bandwidth.
A popular blockchain platform whose smart contracts are not Turing-complete, but can be written in almost any language.
The main advantages of Stellar are almost free transactions ($ 0.01 / 100000 pcs.) and fast confirmation rate (~ 5 sec.). Another feature is the ability to participate in a transaction on the basis of a “smart” contract of more than two parties who confirm their actions by transactions.
Small flaws are also present — limited functionality and a rather complicated instruction for developers of smart contracts.
The Chinese platform, originally developed as an alternative to Ethereum. Supports writing smart contracts in many programming languages. Like Ethereum, the environment for their execution is a virtual machine (NVM), and a fee is charged for deploying smart contracts and interacting with them. But at the same time, GAS is a separate cryptocurrency, which is paid to users as a reward for the NEO cryptocurrency hold.
Another difference is the optimization of the code of contracts before their execution, due to which the maximum efficiency of operations performed in the blockchain is achieved - throughput reaches up to 1000 transactions per second.
In addition to these platforms, the interest of the community of developers of smart contracts are trying to attract projects Next, NEM, Qtum and Cardano. However, so far the number of real dApps in these networks is negligible compared to Ethereum, Tron and EOS.
Differences Between Smart Contracts and Ordinary Contracts
If we compare traditional transactions and executable in a virtual environment through smart contracts, the latter win in almost all possible ways:
- Security. The entire history of the execution of smart contracts is stored on the blockchain, cannot be deleted and changed, while traditional contracts quite often are forged or drawn up for the benefit of one of the parties due to bribery;
- Intermediaries. To draw up ordinary documents, you always need to seek help from specialists (lawyers, notaries, etc.). We also need intermediaries who will monitor the execution of the transaction and, if necessary, apply punishment to its participants (court). To use smart contracts, third-party guarantors are not needed - computer code takes all the roles. It itself monitors the actions of participants and gives the desired result only if everything is clearly consistent with the prescribed conditions (no ambiguous interpretations);
- Reliability. A copy of a once executed smart contract is stored immediately on all nodes of a decentralized network. In turn, a paper document may be lost, including its electronic copy, for example, due to an attack on government agencies' servers;
- Time and effort. To complete a “smart” contract, you only need to make a couple of clicks with the mouse, while ordinary contracts require visits to various instances and lengthy preparation in the form of a collection of certificates and copies of documents.
Among other things, it is worth mentioning that classic transactions are executed in the legal language, and smart contracts — in the computer language. Wherein, in the first case, fiat money is used for money transactions, and in the latter case — cryptocurrencies, which eliminates the need for interaction with banking and other financial institutions.
Advantages and Disadvantages of Smart Contracts
Smart contracts have undeniable advantages:
- Independence — no need to look for a specialist who will act as an intermediary / guarantor of the transaction;
- Security — a smart contract is stored on the blockchain and cannot be changed or deleted;
- Reliability — each node of the network has a copy; therefore, a “smart” contract cannot be lost or damaged, as can happen with a regular paper document;
- Saving funds — no need to pay for expensive services of specialists (lawyers, insurance agents, etc.), participants will only need to pay a small commission for the nodes that serve the network;
- Saving time — it will take several minutes to conduct a transaction, even the most serious and complex. No need to visit various instances, make copies of documents and receive certificates — just make a couple of mouse clicks.
However, smart contracts are not without drawbacks:
- Bugs and errors — the programmer can make a mistake by writing the code of the smart contract, in which case it will not be executed;
- An insufficient level of blockchain education — smart contracts is a fairly new concept so far, familiar only to technically advanced people;
- The impossibility of making changes is the case when dignity is also a disadvantage. The terms of the smart contract cannot be adjusted, therefore, in the event of a change in circumstances or the emergence of oral agreements, they cannot be added to the existing “smart” contract, it remains only to conclude a new one;
- The complexity of resolving disputes — as a rule, controversial issues of legal transactions executed on paper are resolved in court. However, smart contracts do not yet have any regulatory framework, therefore, the court, most likely, will not undertake to consider disputes arising from the transaction through a smart contract.
Areas of Use of Smart Contract
At the moment, smart contracts are not widely used and many projects exist only "on paper". But if you analyze the capabilities of smart contracts, it immediately becomes clear that their scope is very wide, much wider than the use of conventional cryptocurrencies.
We will briefly consider only a few examples of the use of smart contracts, since a detailed examination of each area will take more than one page.
Ethereum smart contracts have gained immense popularity due to their widespread use in ICOs. Today, dozens of ICOs are held monthly and most of them are based on the ERC 20 standard.
First of all, blockchain was developed as a financial instrument, so it is not surprising that smart contracts have huge potential for use in the banking and financial sectors.
Banks mainly play the role of a guarantor or “custodian” of funds. Blockchain, thanks to its distributed and, most important, independent and reliable register, can perform these functions at a much higher level.
Banks do not like cryptocurrencies because of their anonymity and decentralization, but they carefully study the blockchain technology and apply it in their products. As an example, we can name the Swiss bank UBS and the British Barclays, which, using blockchain applications, simplified and accelerated the process of concluding deals.
In addition, smart contracts made available cheap international payments, for which banks often charge a fairly large commission. For this, you can use any cryptocurrency.
As a “clean” project in the financial sector, using smart contract technologies, we can name the Ripple cryptocurrency and its RippleNet network.
Smart contracts in the insurance industry have great potential, since the technology of “smart” contracts allows you to clearly state the conditions under which the policyholder automatically receives payments. Insurance premiums are also deducted from the policyholder’s account monthly on the day specified in the conditions.
Allianz, a large German company, uses smart contracts to automate insurance claims in the event of natural disasters. And startup Dynamis offers fully decentralized insurance. Interestingly, the decision to issue insurance payments is made based on the analysis of the current status of the LinkedIn profile.
Smart contracts will automate typical real estate transactions: rent, mortgage payment, purchase and sale of housing. For example, when renting, the method of locking the door can be used if the tenant does not pay the rent on time. The same applies to housing purchased on a mortgage.
Rent and Purchase of Vehicles
Smart contracts in this area can be applied according to the same algorithm as in the case of real estate. If the client does not extend the rental of a car or bicycle, the vehicle simply will not budge.
Smart contracts will exclude the possibility of falsification of diplomas, as well as make education cheaper and better. Communication between the teacher and the student takes place directly, in addition, students will be able to leave feedback after completing the training and the teacher’s reputation will forever remain in the memory of the blockchain.
Blockchain training will also be a plus for employers, as they can always verify information about potential employees. The concept of training based on blockchain technologies was implemented in the Ntok project.
Network security for all its existence has been and is one of the most acute problems. And given the fact that the data array is constantly growing, ensuring quality cybersecurity has become a necessity, not a whim. And blockchain and smart contracts can do just fine with this. Firstly, the data sent will be safe, and secondly, the information cannot be intercepted / modified / deleted.
Smart contracts can also develop cloud storage based on blockchain technologies: usage fees will be much lower, and data will be more secure thanks to a distributed registry. An example is the Storj project.
Smart contracts and blockchain will be able to provide transparent and reliable elections, the results of which cannot be faked. That is why some countries intend to introduce this progressive system into the voting process in the future.
So, in the state of West Virginia, USA, local authorities as an experiment have already provided the opportunity to cast their votes by using a blockchain application to the military, who cannot personally come to the polls.
The use of smart contracts in the registration of copyrights and registration of patents will completely eliminate the theft of intellectual property and forgery of documents when patenting new technologies and products.
Smart contracts are a unique idea that in the future can completely change our lifestyle and the world as a whole. The most interesting thing is that this technology can be applied in almost any industry. Due to its versatility and unlimited possibilities, smart contracts attract the attention of not only private companies and individual developers, but also entire states.
However, for full adaptation, a serious refinement of the technology will be required so that it becomes safe and does not require special knowledge in programming. And also, cooperation with state regulators, which should optimize the legislative framework for concluding contracts on the blockchain, cannot be dispensed with.