以太坊因为智能合约的加持,成了全球市值第二的区块链项目。那么,智能合约是什么呢?今天我们就来解析一下。
Ethereum has become the second large blockchain project in the world by market value because of the blessing of smart contracts. So what is a smart contract? Today we are going to analyze it.
1. 智能合约是什么?
1. What is Smart Contracts?
“智能合约”这个概念最初由计算机科学家、加密大师尼克·萨博在上世纪90年代初提出。1994年,他的论文《智能合约》,是智能合约领域的开篇之作。四年后,他设计出一种叫做“比特黄金”(Bit Gold)的去中心化数字货币机制,被公认为比特币的直接先驱。在这个机制里,智能合约体现为加密货币和E编程语言的一个主要功能。
The concept of "Smart Contracts" was originally proposed by computer scientist and cryptographer Nick Saab in the early 1990s. In 1994, his paper "Smart Contracts" was the beginning of the field of smart contracts. Four years later, he devised a decentralized digital currency mechanism called Bit Gold, which was recognized as a direct pioneer of Bitcoin. In this mechanism, smart contracts were embodied as a major function of cryptocurrency and E programming languages.

智能合约是怎么定义的呢?智能合约是一种代码和数据的集合,寄存于区块链的特定的地址。简单地说,智能合约像一个在区块链中的自动化代理机制:它有一个账户地址,在时间或事件的驱动下,能够自动执行被预先设定的行动,比如,在两个节点之间传递信息,修改区块链的状态(账户信息等),以及图灵完备计算(图灵完备是指可以用图灵机做到的所有事情,通俗来说就是一般编程语言可以做的所有事情)。
How is the Smart Contracts defined? A smart contract is a collection of code and data that is registered at a specific address in a blockchain. Simply put, a smart contract is like an automated proxy mechanism in a blockchain: it has an account address that, under the drive of time or events, automatically performs pre-defined actions. For example, passing information between two nodes, modifying the state of the blockchain (account information, etc.), and Turing's complete calculations (Turing complete refers to everything that can be done with the Turing machine, which is generally all that a general programming language can do).
智能合约与普通合约相比,其不同点在于:判别条件的评估与执行都由计算机代码自动完成,不需要建立与第三方的信任关系,来为合同的权威性背书。比如,如果A购买一套沙发,需要支付给B 8000元,要求3个月之内完成交付。智能合约代码会自动执行判定,判断A是否支付给B 5000元,以及是不是在三个月内执行交付的。这个智能合约一旦执行,双方都无法更改.
The difference between a smart contract and a normal contract is that the evaluation and execution of the discriminant condition are automatically completed by the computer code, and there is no need to establish a trust relationship with the third party to endorse the authority of the contract. For example, if A buys a set of sofas, it needs to pay B 8,000 yuan, and it is required to complete the delivery within 3 months. The smart contract code will automatically perform the decision to determine if A is paying $5,000 and whether it is delivered within three months. Once this smart contract is executed, neither party can change it.

您应该已经看出来了,智能合约的执行不需要依赖任何第三方的信用背书,也不需要合同当事人双方的信用基础。只要你愿意签署合约(即将合约条款编码成计算机语言),最终合同都会自动执行。它甚至不需要在合约执行出现问题时,寻求律师和法律来纠正,因为它可以及时客观、不可更改地执行合约约定的各事项。因此智能合约的特点包括:
自动地、无需信任地和公正地执行
无需中间人
You should have already seen that the execution of smart contracts does not need to rely on the credit endorsement of any third party, nor the credit basis of both parties to the contract. As long as you are willing to sign the contract (that is, the contract terms are coded into a computer language), the final contract will be executed automatically. It does not even need to seek a lawyer and law to correct when there is a problem with the execution of the contract, because it can implement the contractually agreed matters in a timely and objective and unalterable manner. Therefore, the characteristics of smart contracts include:
Execute automatically, fair, and without trust issue.
No need for a middleman
2
智能合约与保险
智能合约有许多应用场景:从保险、金融或物流,任何交易发生或者契约应用的场合。因为其去中心化和不可篡改的特征,这些交易或者契约执行,可以在没有第三方权威背书机构的情况下自动发生,且不缺失安全性。
以车险理赔为例。当发生微小的事故时,通常情况下我们会选择“私了”,因为通过保险公司理赔的流程冗长复杂。但是,“私了”虽然能在某种程度上快速解决问题,但是因为责任方的违章情况不会被记录在案,违章成本依然很低。
运用智能合约之后,情况就会好转。在保险理赔方面,智能合约可以针对性地解决以上两个问题:效率和违章记录。设想,当你和保险公司签订合同时,合同内容被编译译成代码语言,编程了一个智能合约,如下图所示:
2. Smart Contracts and Insurance
Smart Contracts have many application scenarios: from insurance, finance or logistics, to any transaction or contract application. Because of their decentralized and non-tamperable nature, these transactions or contract executions can occur automatically without the third-party authoritative endorsement, without the lack of security.
Take auto insurance claims as an example. When a minor accident occurs, we usually choose “private”solutions, because the process of claim settlement through the insurance company is lengthy and complicated. However, although “private”solutions can solve the problem quickly to certain extent, the violation of the responsible party will not be recorded, and the cost of violation is still very low.
After using the smart contract, the situation will improve. In terms of insurance claims, smart contracts can solve the above two problems in a targeted manner: efficiency and violation records. Imagine that when you sign a contract with an insurance company, the contract content is compiled into a code language and a smart contract is programmed, as shown in the following figure:

在实际的智能合约中,条文是非常详细、具体的,比如还要考虑到车龄、人员受伤情况、责任方是第几次肇事,等等。上图所示是经过了简化处理。
一旦发生一个事故,满足某个赔付条件,智能合约就会自动执行赔偿,比如上图中的情形1,假如B是责任方,那么智能合约将自动从B的账户中划拨300元,转移到A的账户中,并向交管部门汇报,扣2分。
执行动作一旦完成,就会生成一个记录以上行为的数据区块,上传到网络上每一个节点,比如你和对方的电脑、不同的保险公司,以及交通监管机构。这份记录不可篡改,且永久在线。
In the actual smart contract, the provisions are very detailed and specific, such as taking into account the age of the car, the injury of the person, the times of violations of the responsible party, and so on. The figure above is simplified.
In the event of an accident and a certain payment condition, the smart contract will automatically execute the compensation, such as situation 1 in the above figure. If B is the responsible party, the smart contract will automatically transfer 300 yuan from the account of B to A and report to the traffic control department, deducting 2 points.
Once the execution action is completed, a data block is generated that records the above behavior and is uploaded to each node on the network, such as you and the other party's computer, different insurance companies, and traffic regulatory agencies. This record cannot be tampered with and is permanently online.
3智能合约与贸易
在买卖中,智能合约的运行情况也类似。如果将上面的图换成国际贸易的情形,就是下图。
3. Smart Contracts and Trade
In the sale and purchase, the operation of smart contracts is similar. If the above picture is replaced by international trade, it is the picture below.

假如一个人要和非洲的农户交易,在今天,需要通过跨境贸易公司或者阿里巴巴等跨境电商。如果运用智能合约技术,就可以省去这样的中间机构,从而也节省了中间费用。还有众多的仓储、清关、检验检疫、物流等流程,如果智能合约也应用在这些场景,那么可以节省的时间和金钱成本将是极其可观的。
If a person wants to trade with African farmers, nowadays, cross-border trading companies or cross-border e-commerce such as Alibaba need to be adopted. If smart contract technology is used, such an intermediary can be eliminated, thereby saving intermediate costs. There are also numerous processes for warehousing, customs clearance, inspection and quarantine, logistics, etc. If smart contracts are also applied to these scenarios, the time and money costs that can be saved will be extremely substantial.
当然了,这儿有一个问题需要解决:触发条件造假。比如A发货、B收货,如果一定要人为参与,就变得不“智能”了,因为A可以在没有发货的情况下,向智能合约输入”已经发货“的指令;或者B在已经收货的情况下,忘记向智能合约发送“收货”的指令。这笔交易产生问题的几率还是很高。解决这个问题,需要智能合约和其他技术的结合,特别是区块链+物联网。
Of course, there is a problem here that needs to be solved: trigger condition fraud. For example, A as delivery, B as receipt, if people must be involved, it will not be "smart" anymore, because A can enter the "already shipped" instruction to the smart contract without delivery; or B in the case of receipt, forgets to send a "receipt" order to the smart contract. The chances of this transaction generating a problem are still high. To solve this problem, we need a combination of smart contracts and other technologies, especially the blockchain + Internet of Things.

如上图所示,当A的“100kg品优大红袍”离开他的仓库时,通过RFID(无限射频识别,一种广泛用于物联网的技术)扫描“100kg品优大红袍”的全球唯一识别码,在系统上记录一条类似于“2018年8月2日16:43,从仓库A发出100kg一级大红袍,由V送达B”的信息,然后将这条记录生成一个新的数据区块,上传到A与B都在的区块链。接着,该记录在全网广播,被每个节点记录:代理商、食品监督机构、海关、检验检疫机构、物流公司、工商税务机关、其他茶叶生产商等等。
As shown in the above figure, when A's “100kg Pinyou Dahongpao” leaves his warehouse, it scans the globally unique identification of “100kg Pinyou Dahongpao” through RFID (infinite radio frequency identification, a technology widely used in Internet of Things), and records a message on the system similar to "16:43 on August 2, 2018, 100kg first-class Dahongpao from warehouse A, delivered by V to B". And then, a new data area for this record will be generated and upload to the blockchain where both A and B are in. Then, the record will be broadcast on the whole network and recorded by each node: agents, food inspection agencies, customs, inspection and quarantine agencies, logistics companies, industrial and commercial tax authorities, other tea producers, and so on.
当“100kg品优大红袍”进入仓库B时,同样的,通过RFID扫描这批货物的ID,在系统上记录“2018年8月5日20:23,由仓库B接收100kg一级大红袍,由V从A送达”,也会上传到区块链。
通过以上技术方式,一旦“货物X离开仓库A”“货物X抵达仓库B”这样的信息所在的两个数据区块,其哈希值相互匹配,那么就满足智能合约的执行条件,合约就会自动执行“从B的账户中转移XX万元给A”的指令。
When “100kg Pinyou Dahongpao” enters warehouse B, the same ID is scanned by RFID, and the system records ‘20:23 on August 5, 2018, received 100kg of Dahongpao from warehouse B, delivered by V from A’ and will also be uploaded to the blockchain.
Through the above technical means, once the data values of the two data blocks where the information of "goods X leaves the warehouse A" and "goods X arrives at the warehouse B" match each other, then the execution conditions of the smart contract are satisfied, and the contract will automatically execute the instruction of “transfer XX yuan from account B to A”.
4 上面两个例子仅仅是智能合约在未来的商业应用中的两个领域,其实有更多的领域可以用到智能合约。智能合约“去中心化”的过程,就是个人价值扩大的过程。我们坚信,一个“没有中间商赚差价”的时代,一个没有“物次价高”的商业欺瞒的时代,价值互联网上的价值流通,必将更加纯粹与高效,从而迎来一个商业文明新纪元。
4.The above two examples are just two areas of smart contracts for future commercial applications. In fact, there are more areas where smart contracts can be used. The process of “decentralization” of smart contracts is the process of expanding personal value. We firmly believe that in an era of “no middlemen earning a price difference”and “no bullying by high price and low quality”, the value circulation on the value of the Internet will be more pure and efficient, thus leading us to a new era of commercial civilization.