Author: University of Aeronautics and Astronautics Laboratory Distributed Innovation Institute Yunnan, Beijing and Beijing University of Aeronautics and Astronautics Professor Hu Kai
Many people in the industry often don't know the smart contract. Some people think it is the original content of the blockchain, some think it is used for issuing coins, and some think it is the application on Ethereum. Wait, these understandings completely overwhelmed the meaning of smart contracts and severely restricted the development and application of smart contracts. So what is a smart contract? What does it do? What is its essence? What's the point of it? What's wrong with it? How does it work? Where is its road to development?
1. The origin and significance of smart contracts
In recent years, blockchain has become a hot technology. As an application technology, its rapid development and upsurge are rare. Why has it attracted the attention of people from all walks of life? There are many analyses and cognitions, but the author believes that there are two most important reasons. One is that blockchain is not a separate technology. It is not only a fusion of many technologies, but also involves social governance models and changes in thinking Ideological technology, this kind of ideological technology will motivate people to innovate and produce a technological revolution; the second is that blockchain technology caters to the important development tide of the current society, that is, how human society is developing into a digital society (Gartner report 2016), what is the future? It is a huge challenge for technology and social governance to transfer the dependency relationships of people's life modes, credit, laws, and even culture to the virtual world. Blockchain-related technologies are an important technology to meet this trend. one.
- Wanxiang and Xiao Feng's blockchain map: you can see the "tip of the iceberg"
- Or the strongest outlet in the next 10 years: the era of industrial blockchain is officially coming
- China's blockchain ambition: Who is it?
- Gu Yanxi: Libra is a subversive of the existing financial market structure
- BMW, GM, etc., the world's top five automakers, collaborate to test block identity-based automotive identity systems
- What about Bitcoin network congestion? Cut to cure - Secure the Bag safety bag technology
We can look at a future car transaction scenario: car loans. If the lender does not repay, a contract program will automatically recover the digital key that started the car. Car dealers will find this automatic contract use very attractive. This example is a scenario given by cryptographer Nick Szabo in 1994, and it is also the first time that he proposed the concept of "Smart Contract (SC). Compared with the more complex involving users, car dealers With bank loan behaviors and procedures, smart contracts are computer programs that can automatically execute the terms of the contract. By observing the vending machine (see Figure 1), Saab realized that the machine controls the property through a physical sealing system and can be programmed to execute automatically "Contract" clauses point out that computer code can replace mechanical equipment for more complex digital property transactions. Someday in the future, these programs may even replace lawyers and banks that handle certain specific financial transactions. The way built into the physical entity was created. " Later in 2002, Nick Saab designed a digital currency mechanism called" Bit Gold ", thinking that smart contracts can support electronic data interchange (EDI), Trading of synthetic assets such as securities options.
Figure 1 Enlightenment from vending machine model
He then creatively abstracted that "smart contracts are computable transaction protocols that execute contract terms." This simple and simple abstraction has far-reaching significance because it involves the most basic human socioeconomic activities: transactions and agreements. And it is done by calculations (programs). The potential for the future digital society is obvious, because it programs the complex relationships between people, transactions, legal agreements, and the virtual world of the Internet. Maybe one day we will be surprised to find that contracts, lawyers, notaries, insurance, Some functions of exchanges, banks, and even courts are replaced by smart contracts (procedures). This shows that the concept of smart contracts is broad and profound. In the long history of technological development, many simple and natural ideas are often a cornerstone of development. Smart contracts are likely to be one of the cornerstones of a digital society. Just like the network construction and online application relationship during the development of the Internet, as the ubiquitous smart contract application on the chain will be the most important and active technology in the blockchain wave.
2. Definition of smart contract
There are many informal definitions of smart contracts. Here are a few examples for everyone to understand the essence and meaning of smart contracts from different perspectives:
1) Smart contracts facilitate contract execution through the use of protocols and user interfaces (Nick Saab);
2) A smart contract is a contract written in program code, and its terms are executed by a program (Mark S. Miller);
3) Smart contracts are programs that can directly control digital assets based on the blockchain. (Ethereum)
4) Smart contract is a computer program running on a copyable, shared ledger that can process information, receive, store, and send value.
5) A smart contract is a piece of code that is deployed on a shared, replicated ledger. It can maintain its own state, control its assets, and respond to received external information or assets.
6) The definition given by Wikipedia is:
"Smart contracts are computer protocols that facilitate, verify, or enforce the negotiation or performance of a contract, or that obviate the need for a contractual clause. Smart contracts usually also have a user interface and often emulate the logic of contractual clauses. Proponents of smart contracts claim that many kinds of contractual clauses may thus be made partially or fully self-executing, self-enforcing, or both. Smart contracts aim to provide security superior to traditional contract law and to reduce other transaction costs associated with contracting. "
In general, a smart contract is a set of commitments defined in digital form, including an agreement on which contract participants can execute these commitments.
3. Smart contract development stage
The smart contract theory proposed by Saab appeared almost at the same time as the World Wide Web, but its application practice has been seriously behind the theory, and no clear path has been found to transform this idea into reality. There are three main problems. First, the assets need to be digitized and the ledger of digital assets; second, the contracting party needs a trusted execution environment; third, code contracts need to have similar contract stamps that cannot be changed at random and can be audited. The emergence of blockchain technology has solved these problems, which has triggered the application of smart contracts. The blockchain lays the foundation for the recording and transfer of fully digital assets. Through fully digital assets and distributed ledgers, the blockchain enables computer code to control assets. The control of assets is to control the keys corresponding to the assets, not any physical objects. . The blockchain has also become the most trusted mechanism on the Internet. At the same time, once the smart contract code makes a block into the blockchain, the contractor can be sure that the contract will not be changed. Can be filed, monitored and audited.
Below is a smart contract that executes automatically and has the basic functions of a bank. There are four functions: query account balance, save money, withdraw money, and transfer money. The contract codes are shown in Table 1.
Table 1 A simple bank smart contract
Contract establishment and execution: first compile the above contract code into code, and then establish a contract account on the blockchain to store the contract and manage contract-related data. When you need to check the balance, send a message to the contract account and call balance (); when you need to transfer, call transfer (), and the contract account will automatically subtract your money from the transfer amount and increase the corresponding amount to the counterparty's money; When you need to deposit money, call deposit (), the contract account will automatically increase your money amount; when you need to withdraw, call withdraw ().
It can be seen that this is a simple contract, and the second-generation blockchain represented by Ethereum has triggered the upsurge of blockchain due to the integration with this simple smart contract. The author predicts that the development of smart contracts can also be divided into three generations:
The first generation is currently used by a lot of simple on-chain code (IBM) called on-chain code, most of which are contracts with simple IF-THEN-ELSE statements in current Ethereum projects, just some simple process code , There is no complexity logic and intelligent content;
The second generation is a contract-type smart contract that has been or will be widely used to express the contract relationship code. For example, shopping contracts, rental contracts, doctor-patient relationships, insurance relationships, retrospective contracts, etc. have certain commitments and agreed intelligent expressions. These can be converted into codes by lawyers or ready-made contract templates. Smart contract;
The third generation will be the high-level or smart era of smart contracts, which is represented by code as a legal contract: it has certificates and criteria, and conforms to legal regulations or the coding of legal rules. It is a smarter and higher-level contract, which the author believes is also smart. The most promising development of the contract.
4. Problems and Solutions of Smart Contracts
It should be said that the current smart contracts on the blockchain are still in the early stages of technology. They are immature, insecure, and unintelligent. They have not formed a theoretical system and cannot meet the needs of applications on a large scale. The main problems are:
1) The scale of smart contracts creates problems: Like the software development process, it can be expected that smart contracts need to be produced on a large scale. How to produce trusted smart contracts on a large scale is a big problem. The smart contract project proposed by the author is a well-planned theory ;
2) Smart contract public letter writing problem: As a code contract, it is very different from text protocols in terms of how to write public letter, who will verify and test? The parties to the contract are obviously inappropriate, and it is difficult for ordinary third parties to have a credible position. The establishment of a credible production mechanism is the key to development;
3) The credibility of smart contracts: Since smart contracts are special software that manages huge digital assets, the problem of software bugs is very prominent. Software traps will obviously benefit one party to the contract. How to check and repair the contract? ? How to verify the logic of the contract and eliminate loopholes? Formal methods are an important means of software credibility verification at present, to avoid similar opportunities to hackers due to loopholes in the code itself;
4) The intelligent problem of smart contracts: At present, it is basically a simple contract or a fixed contract template. The language, writing, deployment, auditing, automatic assistance tools, and dynamic modification of smart contracts are all new models. The combination with artificial intelligence technology is Research trends
5) Legality: Does a smart contract have the same legal effect as a "real" contract? What if the result of a smart contract violates the law, or the court finds that it conflicts with contract law? Computational jurisprudence is only a study of legalization, and the author proposes the technology of legal codes to solve the problems of codes, which are legal issues;
6) Smart contract execution problem: When there are multiple contracts that require time to trigger, who will manage and send the event to be triggered? If multiple contracts are executed at the same time, it will bring complex access control, synchronization and consistency issues;
7) Performance issues: Distinguishing the consistency process of the contract status from the consistency process of the blockchain may increase the block production time. For example, the block construction time includes the processing time of transactions in the block. Slowing down the speed of building blocks, how can I speed up contract execution efficiency?
Of course, there are still many technical implementation problems. This series of articles will introduce a lot of ideas, and everyone will discuss the ways to solve these problems.