What is A Smart Contract?
Welcome to the Bixiaobao Blockchain Open Course! This episode is about what a smart contract is.
I. Introduction
Smart contracts are one of the core technologies of blockchain. The concept was first proposed by Nick Szabo in 1995. A smart contract is a computer program that automatically executes commands under certain conditions.
Nick Szabo’s smart contract is an extensive concept. A vending machine, for example, is a smart contract system that dispenses items automatically after the user selects the item and completes the payment. Another example is that the automatic repayment of credit cards is also a smart contract. After setting the automatic repayment method, the payment will be automatically deducted when due.
Currently, smart contract usually refers to the smart contract in the blockchain industry.
In 2008, Satoshi Nakamoto first applied smart contract to Bitcoin, but it did not attract the attention of the market immediately because of its simple function. This is also known as the era of blockchain 1.0.
Back to the end of 2013, V God, the founder of Ethereum, released a white paper titled “Ethereum: Next Generation Smart Contract and Decentralized Application Platform”, which officially opened the era of blockchain 2.0 represented by smart contract.
Under the leadership of Vitalik Buterin, the Ethereum team officially launched Ethereum public chain in 2015, which is an open-source public chain platform with smart contract creation capabilities. With the Ethereum public chain platform, developers can quickly draft a smart contract.
Since then, smart contracts have become an integral part of the Ethereum ecosystem, with various smart contracts springing up, setting the stage for the boom of Decentralized Finance (DeFi) in 2020.
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. The code controls the execution, and transactions are trackable and irreversible.
Compared with traditional contracts, smart contracts solve the problem of trust. Traditional contracts rely on the legal endorsement, when there is a breach of contract, it needs to rely on the court and other administrative forces to deal with. Smart contract is not only the electronic version of the traditional contract, but is to change the endorsement and execution of the traditional contract from the law process to the code. Once external conditions are met, the smart contract will be implemented automatically without human intervention and is mandatory.
As a result, many tech geeks in the blockchain area embrace the spirit of “code is law”.
II. Advantages
Decentralization: The execution of a smart contract does not depend on the participation or intervention of a third party. The supervision and arbitration of the contract are completed by computers.
Imtamperability: Once a smart contract is deployed, nothing can be modified and no one can interfere with the execution of the contract. Like a contract in the real world, once it’s signed, you can’t change it.
Low cost: As smart contracts do not need the supervision of a third-party intermediary, once the contract is broken, the code is enforced, which has lower cost compared with traditional contracts.
Openness and transparency: Once the smart contract is successfully deployed, it will run according to the code, and anyone can view it with high transparency.
III. Shortcomings
Smart contracts are not without their drawbacks. Because smart contract code cannot be modified once deployed, which means that it is highly likely to be exploited once the code has bugs, the fault tolerance of smart contract is extremely low.
In fact, The smart contract of blockchain has been attacked by hackers for many times since its birth, and The once sensational event The DAO is one of them.
In 2016, The DAO launched a crowdfunding and raised $150 million worth of Ethereum in just one month. However, hackers found a flaw in The DAO’s smart contract and attacked it. A large amount of Ethereum was stolen by hackers. Because once a smart contract is deployed and cannot be modified, there is nothing the team can do, and the huge assets are gradually lost. Subsequently, the founder proposed a scheme to roll back the transaction. It was also the first time in the history of blockchain to roll back the transaction time. As some users in the community did not agree with the decision, Ethereum had to choose hard fork.
Similarly, bZx, a lending protocol, has been hacked several times due to a flaw in its smart contract. On February 15, 2020, bZx team issued an announcement on the official telegram group, saying that hackers had carried out vulnerability attack on its protocol. As a result, 350,000 dollars’ worth of ETH was stolen. On September 14, bZx was attacked again, and this attack resulted in a total loss of approximately $8 million.
The events above show that the development of smart contracts is still in an early stage and there are many problems. Bixiaobao also reminds you that investment in blockchain needs to be rational.
IV. Applications
There are many applications for smart contracts, such as decentralized lending. Users deposit Ethereum into a pool of funds as collateral, and then lend out a certain amount of the stablecoin DAI. Because there is collateral, the lender will not be worried about the solvency. When the collateral value is insufficient, the system will automatically trigger liquidation, to ensure the lender’s rights and interests.
Smart contracts can also be used for crowdfunding. The project owner first initiates a crowd-funding through the contract, and the user sends a certain amount of ETH and other tokens to it. When the crowdfunding is completed, the smart contract will automatically send the project token to the wallet. In 2017, a large number of projects funded this way, and some of them are excellent, such as Loopring and Polkadot. In this way, the project party has completed the financing and provided stable funds for the project to grow bigger and stronger. Investors have reaped huge returns, such as Ethereum crowdfunding launched in 2014 that returned more than 1,000 times, and BNB’s crowdfunding in 2017 that returned hundreds of times.
The third smart contract scenario is Decentralized Finance (DEFI). Decentralized financial applications are in full swing in 2020, which has something to do with the popularity of smart contracts.
Further segmentation of decentralized finance includes lending, trading, stablecoin exchange, derivative assets, etc. In the case of Uniswap, the user becomes a liquidity provider and receives LP tokens. Later, the user pledges LP tokens and receives UNI, a process also known as mining.
Since the launch of liquidity mining, Uniswap has exploded in trading volumes, and has become the world’s largest decentralised exchange, overtaking Coinbase, the largest exchange in the US.
In short, despite shortcomings, smart contracts still have a broad application prospect. We believe that as the industry develops, smart-contract-related technologies will gradually mature, when hacker attacks may become a thing of the past.
Blockchain Open Course is an introductory course on blockchain by BiXiaoBao.
For more blockchain knowledge, follow the column of Bixiaobao.
References: