Smart Contract Series 1: The Cornerstone of the Digital Society – Smart Contracts

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 about Smart Contract. Some think it is the content that comes with the blockchain. Some think it is used for issuing money. Some think it is the application of Ethereum. Wait, these understandings completely overwhelm the meaning of smart contracts and seriously restrict the development and application of smart contracts. So what is a smart contract? What does it do? What is its essence? What is the meaning of it? What is the problem with it? How does it apply to the ground? Where is its development path?

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 enthusiasm are rare. Why is it concerned by people from all walks of life? There are a lot of analysis and understanding, but the author believes that there are two most important reasons. First, the blockchain is not a separate technology. It not only contains a lot of technology integration, but also involves social governance models and thinking changes. Ideological technology, this kind of ideological technology will encourage 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, the development of human society into the digital society (Gartner Report 2016), how will the future Transferring the patterns of life, credit, law, and culture of people in the physical society to the virtual world is a big challenge for technology and social governance, and blockchain-related technologies are important technologies to cater to this tide. one.

We can look at the future of a car trading scenario: car loans, if the lender does not repay, a contract procedure will automatically recover the digital key to launch the car, car dealers will find this automatic contract use is very attractive. This example is a scenario given by cryptographer Nick Szabo in 1994, and he first proposed the concept of “Smart Contract (SC). Compared to the complex user, car dealership And the bank's loan behavior and procedures, the smart contract is a computer program that can automatically execute the contract terms. Through the observation of the vending machine (Figure 1), Saab realizes that the machine controls the property through the physical sealing system, and can be programmed to execute automatically. The "contract" clause states that computer code can replace mechanical equipment for more complex digital property transactions. One day in the future, these programs may even replace lawyers and banks that deal with certain financial transactions, ie "smart property can be smart contracts." The way built into the physical entity was created . Then in 2002, Nick Sabo designed a digital currency mechanism called Bit Gold, which believed that smart contracts could support electronic data interchange (EDI), Trading of Synthetic Assets such as securities options.

Figure 1 Revelation of the vending machine model

He further creatively abstracts that "smart contracts are computable transaction protocols for implementing contractual terms." This simple and plain abstraction has profound implications because it involves the most basic human socioeconomic activities: transactions and agreements. And it is done by calculations (programs). This potential for the digital society of the future is obvious because it procedles 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 the broadness and profoundness of the concept of smart contracts. In the long history of technological development, many simple and natural ideas are often a cornerstone of development. Smart contracts are probably one of the cornerstones of the digital society. Just like the relationship between network construction and online application in the development of the Internet, the ubiquitous smart contract application in the chain will be the most important and active technology in the blockchain wave.

2. Definition of smart contracts

There are many informal definitions of smart contracts. Here are a few examples for you to understand the essential meaning and meaning of smart contracts from different perspectives:

1) Smart contracts facilitate the execution of contracts by using protocols and user interfaces (Nick Saab);

2) A smart contract is a contract written in program code whose terms are executed by the program (Mark S. Miller);

3) Smart contracts are procedures based on blockchain that directly control digital assets. (Ethereum)

4) A smart contract is a computer program that runs on a copyable, shared book 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 that maintains its state, controls its assets, and responds to incoming 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 agreements on which contract participants can execute these commitments.

3. Smart contract development stage

Saab's smart contract theory almost coincided with the Internet (World Wide Web), but the application practice has been seriously behind the theory, and there is no clear path to turn this concept into reality. Mainly faced with three aspects, one is the need for digitization of assets and the accounting of digital assets; the second is that the contractor needs a trusted execution environment; the third is that the code contract needs to have a similar contract seal and cannot be arbitrarily changed and auditable. The emergence of blockchain technology has solved these problems and triggered the application of smart contracts. The blockchain lays the foundation for the recording and transfer of fully digital assets. With fully digital assets and distributed ledgers, blockchain enables computer code to control assets. Asset control is the key to controlling assets, not any physical objects. . The blockchain has also become the most credible mechanism on the Internet, and once the smart contract code blocks into the blockchain, the contractor can confirm that the contract will not be changed, as if the contract was covered with a red stamp, due to the opening of the blockchain. Sex can be filed, regulated and audited.

Below is an automated contract that has the basic functions of a bank. There are four functions: query account balance, save money, withdraw money, transfer, the contract code is shown in Table 1.

Table 1 A simple bank smart contract

The establishment and execution of the contract: first compile the above contract code into code, and then create a contract account on the blockchain for storing contracts and managing contract-related data. When you need to check the balance, send a message to the contract account to call balance(); when you need to transfer, call transfer(), the contract account will automatically subtract your money from the transfer amount, and increase the corresponding amount to the other party's money; When you need to save money, call deposit(), the contract account will automatically increase your money; when you need to withdraw money, call withdraw().

It can be seen that this is a simple contract, and the second-generation blockchain represented by Ethereum is precisely due to the fusion of this simple smart contract and the blockchain boom. The author predicts that the development of smart contracts can also be divided into three generations:

The first generation is currently using a lot of simple on-chain code (IBM) called chain code, mostly the contract of the simple IF-THEN-ELSE statement in the current Ethereum project, just some simple process code. , no complexity logic and intelligent content;

The second generation is a contractual smart contract that has been or will be widely used, and a code that expresses a contractual relationship. For example, contracts for shopping, contracts for rent, doctor-patient relationship, insurance relationship, traceability, etc., have certain commitments and agreed-upon intelligent expressions. These can be converted into code formation through lawyers or ready-made contract templates. Smart contract

The third generation will be the advanced or intelligent era of smart contracts. It is represented by code as a legal contract: it has a certificate and a certificate, and it is a code that is in line with legal regulations or legal rules. It is a smarter, more advanced contract. I think it is also intelligent. The most promising development of the contract.

4. The problem of smart contract and the solution

It should be said that the current smart contract on the blockchain is still in the early stage of technology, is immature, unsafe and unsmart, and does not form a theoretical system. It cannot meet the needs of the application on a large scale. The main problems are:

1) The problem of the scale of intelligent contracts: As with the software development process, it can be expected that smart contracts require large-scale production applications. How to scale the production of trusted smart contracts is a big problem. The smart contract project proposed by the author is a precautionary theory. ;

2) Smart contract writing problem: As a kind of code contract, the big difference with the text protocol is how to write a letter, who will verify and test? It is obviously inappropriate for the parties to the contract. It is difficult for the general third party to have a public trust position. Establishing a public credit production mechanism is the key to development;

3) The credible problem of smart contracts: Since smart contracts are special software for managing huge digital assets, the problem of software bugs is now very prominent. Software traps will lead to a party that is obviously beneficial to the contract. How to check and repair the contract? ? How to verify the logic of the contract and eliminate the loophole? Formal methods are an important means of software credibility verification at present, avoiding opportunities similar 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 aiding tools, and dynamic modification of smart contracts are all new models, combined with artificial intelligence technology. Research trend

5) Legitimacy question: 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 if the court finds that it has conflict with the contract law? Computational law is only a matter of studying legalization, and the author proposes legal code technology to solve the code, that is, legal issues;

6) Smart contract execution problem: When there are multiple contracts that need 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 concurrency, and consistency issues;

7) Performance problem: Differentiating the consistency process of the contract state from the consistency process of the blockchain may increase the production time of the block. For example, the construction time of the block includes the processing time of the transaction in the block. Slow down the speed of building blocks, how to speed up contract execution efficiency?

Of course, there are still many technical implementation problems. This series of articles will lead you to the topic of solving these problems.