A smart contract is a computer code (algorithm) designed to support the operation of commercial contracts in the blockchain.
The basic principle of smart contracts is that they allow you to exchange assets (money, shares, real estate, etc.) without resorting to intermediaries. The algorithm acts as a guarantor of fulfillment of obligations for both parties.
Why do we need smart contracts?
Bitcoin and other blockchains allow users to make transactions directly, that is, to transfer assets to each other without intermediaries. Such economic relations in the network are called person to person or p2p. The task of smart contracts is similar, that is to remove intermediaries in the form of banks, lawyers, notaries, etc., when implementing commercial contracts. The smart contract must contain the obligations of the parties, the performance of which the contract monitors. Then it acts according to the specified logic of the contract. For example, it transfers funds in full, if everything is in order, or fines for late delivery.
Who invented smart contracts?
The idea of a smart contract was announced in the mid 90-s by cryptoanalysts Nick Szabo. A little later, he came up with the concept of Bit Gold cryptocurrency. After almost 20 years, Satoshi Nakamoto would write that Bitcoin was developed based on the solutions applied in Bit Gold, which was never implemented.
For the first time, smart contracts were implemented on the Ethereum blockchain. Vitalik Buterin specially designed the network in such a way that it was possible to implement absolutely any smart contract.
Can I use smart contracts in the Bitcoin network?
The Bitcoin blockchain supports the implementation of simple smart contracts, but due to the network structure, their capabilities are severely limited. At the moment, there are several sidechains (mechanisms) of the main blockchain for the application of smart contracts, but these solutions are not popular among developers.
How does a smart contract work in the Ethereum network?
In the Bitcoin network, miners make transactions, including them in new blocks, and receive a commission for it. Making a transaction (in other words, mining) in the Ethereum network takes place in a similar way. The fundamental difference between networks occurs at the stage when the smart contract is called. The miner’s computer finds this contract and runs its code with the necessary parameters inside its virtual machine (EVM-Ethereum Virtual Machine). Every miner does this, but only one person will be able to announce the result to the network and pick up the award, as always.
Smart contracts cost
For the execution of each line of the smart contract, the person calling it will have to pay a reward to the miners. In this case, if the reward is not enough, the fulfillment of the conditions is terminated, and the smart contract is not executed until the end. If the amount of the reward is higher than what the miner is entitled to, the unspent funds are returned back. Usually the price of such operations is small and is calculated in GWei (Giga wei) = 10-10 ETH.
Where are smart contracts currently used?
The areas of application of smart contracts are quite diverse. They were most widely used in crowdfunding. Most ICO (initial coin offering) are carried out with the help of smart contracts. Usually, such contracts include several stages of ICO with different conditions.
In addition to ICO, there are other areas of application of smart contracts: digital identity systems, voting systems, marketplaces, labor exchanges, property rights accounting systems, logistics, banking services, insurance, trading (decentralized exchanges) , etc.
Advantages of smart contracts over traditional contracts
The main advantages of smart contracts:
- absence of intermediaries (lawyer, bank, notary, etc.), which reduces operating costs;
- security as the contract is stored in the blockchain and cannot be changed;
- the contract is executed according to mathematical laws and excludes the possibility of other interpretation;
- process automation and acceleration.
Disadvantages of smart contracts
Like any emerging technology, smart contracts have their drawbacks:
- lack of regulatory framework. That means that all such contracts are not regulated at the moment, and the risks associated with them cannot be insured;
- compromise of Oracles programs These services provide contracts with the real world data for their execution: for example, that the goods are delivered to the destination and you can transfer money for logistics. Fraudsters can hack Oracle and, therefore, hack the transaction;
- errors in the code. A smart contract loaded into the blockchain is unchanged, and not all errors can be easily corrected. One of the most striking examples is a bug in the code of the DAO smart contract, which led to the theft of money, and later caused a hard fork in the Ethereum network.