跳到主要内容

📑 Introduction

1. Historical Background 历史背景

In 2013, Ethereum founder Vitalik Buterin adopted the concept of smart contracts in his white paper titled "A Next Generation Smart Contract & Decentralized Application Platform".

2013 年,以太坊创始人 Vitalik 在白皮书中采用智能合约这一概念,其标题就是《下一代智能合约和去中心化应用平台》。

For a long time after the concept was proposed, smart contracts remained a mere idea until the advent of blockchain technology. Initially, Bitcoin scripts made smart contracts possible, but they were not Turing complete and had limited application scenarios. What truly popularized smart contracts was Ethereum.

概念提出后的很长一段时间,智能合约只是一个设想,直到区块链的出现。首先,比特币脚本让智能合约成为可能,但它并不图灵完备,且应用场景有限。真正让智能合约普及开来的是以太坊。

信息

Computer scientist and cryptographer Nick Szabo coined the phrase "smart contract".

计算机科学家和密码学家 尼克-萨博(Nick Szabo)创造了“智能合约”一词。

Szabo’s placement of quotations around the term “smart” when comparing smart contracts to paper-based contracts, and his rejection of artificial intelligence are noteworthy. Smart contracts are "smarter" than paper contracts because they can perform certain pre-programmed stages automatically, but they should not be seen as sentient instruments capable of parsing a contract's more subjective needs.

Szabo 在比较智能合约和纸质合同时,将“智能”一词加上引号,并拒绝了人工智能的概念,这一点非常值得注意。智能合约比纸质合同“更智能”,因为它们可以自动执行某些预编程的阶段,但它们不应被视为能够解析合同中更主观需求的有感知工具。

2. Introduction 简单介绍

"A smart contract is a computerized transaction protocol that executes the terms of a contract. The general objectives of smart contract design are to satisfy common contractual conditions (such as payment terms, liens, confidentiality, and even enforcement), minimize exceptions both malicious and accidental, and minimize the need for trusted intermediaries."

“智能合约是能够执行合约条款的计算机化的交易协议。智能合约的设计目标是满足常见的合约场景(如付款条件、留置权、保密性甚至强制执行),最大限度地减少恶意破坏和意外状况,并最大限度地减少对受信任中介的需求。”

提示

The above is Nick Szabo's definition of smart contract from his paper

以上是尼克-萨博在他的论文中的智能合约定义

Smart Contracts are a set of instructions executed in a decentralized way without the need for a centralized or third party intermediary.

智能合约是一组在去中心化模式下执行的指令,无需第三方或中心化机构来运行它们。

Smart contracts enable the execution of credible transactions without the involvement of third parties.

智能合约可以在没有第三方参与的情况下执行可信的交易。

Smart contracts are computer programs that automatically execute all or portions of an agreement and are kept on a blockchain-based platform.

智能合约是计算机程序,可以自动执行协议的全部或部分内容,并存储在基于区块链的平台上。

“Smart contracts are self-executable and automated computer programs that can carry out the terms of a contract or a business agreement between two or more parties. Smart contracts also have an additional feature of a “value exchange” that is contingent on some pre-agreed terms, in addition to the features of a traditional contract. What distinguishes a smart contract from a normal contract is that firstly it is automated, and secondly, a smart contract can transfer economic value automatically and simultaneously while satisfying the terms of the traditional contract, due to a unique and exclusive feature of a blockchain, without needing a trusted intermediary like a bank, notary, auditor or accountant from the old traditional system.” – Arifa Khan

“智能合约是可以自动执行和自我运行的计算机程序,它们能够执行两方或多方之间的合同或商业协议条款。除了传统合同的特征外,智能合约还具有“价值交换”的附加功能,这种交换基于一些预先约定的条件。智能合约与普通合同的区别在于,首先,它是自动化的;其次,智能合约能够在满足传统合同条款的同时,自动且同步地转移经济价值,这得益于区块链的独特和专属特性,无需传统系统中的银行、公证人、审计员或会计等受信任的中介。”– Arifa Khan

3. Features 特点

  • Autonomy: Smart contracts do not require third-party intermediaries, allowing users to control transactions independently.

  • 自治:智能合约不需要第三方中介,用户可以自主控制交易。

  • Safety: Smart contracts employ encryption and distributed ledger technology to ensure secure and tamper-proof transactions.

  • 安全:智能合约使用加密技术和分布式账本技术,确保交易安全和防止篡改。

  • Speed: By utilizing automation technology, smart contracts significantly reduce transaction times and procedural delays.

  • 速度:智能合约使用自动化技术,减少了交易时间和手续。

  • Savings: Smart contracts cut down on intermediary fees, saving users money.

  • 节省:智能合约减少了中介费用,节省了用户的钱。

  • Accuracy: Automation technology in smart contracts minimizes human error.

  • 准确:智能合约使用自动化技术,减少了人为错误。

  • Transparency: With distributed ledger technology, smart contracts ensure transparency and openness in transactions.

  • 透明:智能合约使用分布式账本技术,确保交易透明和公开。

  • Transaction Atomicity: Smart contracts ensure that transactions are atomic, meaning they either complete successfully or are fully reverted, maintaining the integrity of the overall process.

  • 交易原子性:智能合约确保交易具有原子性,要么完全成功执行,要么完全回滚,从而维护整体过程的完整性。

4. Understand the Details 深入理解

Each node in the blockchain network holds a complete copy of the blockchain, including the code of all deployed smart contracts.

每个节点在区块链网络中持有区块链的完整副本,包括所有已部署的智能合约的代码。

The state of a smart contract (such as the value of variables, balances, etc.) is stored on the blockchain and updated as transactions are executed.

智能合约的状态(例如变量的值、余额等)存储在区块链上,并随着交易的执行而更新。

Nodes verify transactions and update states by executing the logic of smart contracts, but they do not directly hold a copy of the "current state." Instead, they obtain the state from the data on the blockchain.

节点通过执行智能合约的逻辑来验证交易并更新状态,但并不直接持有“当前状态”的副本,而是通过区块链上的数据来获取状态。

Contracts are passive and only execute when invoked by transactions, either directly from EOAs or indirectly through other contracts.

合约本身是被动的,只有在被交易调用时才会执行,可以是来自 EOA 的直接调用或通过其他合约的间接调用。

Smart contracts, once put on a blockchain, are largely unchangeable, even by their author. This makes it more difficult for them to be restricted or shut down.

一旦智能合约被放置在区块链上,基本上是不可更改的,即使是其作者也无法更改。这使得它们更难被限制或关闭。

This rule is not without exceptions.

但这一规则也不是没有例外。

信息

The DAO Attack Incident: In June 2016, a hacker exploited a weakness in the code of the Decentralized Autonomous Organization (DAO), a smart contract based on Ethereum, and stole 50 million Ether. To address the attack, the only way to reverse this was to create an entire copy of the chain where this particular transaction didn’t take place. The Ethereum community decided to implement a hard fork to restore the stolen funds. The hard fork allowed the stolen Ether to be transferred to a new contract address, enabling affected investors to recover their funds. This decision led to the split between Ethereum (ETH) and Ethereum Classic (ETC), with the latter retaining the original chain's state.

The DAO 攻击事件:2016 年 6 月,一名黑客利用基于以太坊的智能合约--去中心化自治组织(DAO)代码中的一个弱点,盗取了 5000 万以太币。为了应对这一攻击,扭转这种情况的唯一方法是创建一个没有发生该特定交易的链的完整副本。以太坊社区决定进行硬分叉(hard fork),以恢复被盗的资金。硬分叉的实施使得被盗的以太币能够被转移到一个新的合约地址,受影响的投资者得以取回他们的资金。这一决定导致了以太坊(ETH)和以太坊经典(ETC)的分裂,后者保留了原始链的状态。

Smart contracts are made up of three main parts:

智能合约主要由三个部分组成:

  • The first are the signatories or the parties to the smart contract. Digital signatures are used in smart contracts to accept or reject contractual obligations. The agreement is "signed" using a person's crypto wallet.

  • 第一个是智能合约的签署方或参与方。在智能合约中,使用数字签名来接受或拒绝合同义务。协议通过个人的加密钱包进行“签署”。

  • The second is the topic or content of contract. A person, for example, may agree to buy a certain quantity of Bitcoin.

  • 第二个是合同的主题或内容。例如,一个人可能同意购买一定数量的比特币。

  • The third: The exact conditions involved, such as the current Bitcoin price.

  • 第三个是涉及的具体条件,例如当前的比特币价格。

5. Wrapping Up 总结

Smart contracts are now a model illustration of "Amara's Law" the notion described by Stanford University computer scientist Roy Amara that humans tend to overestimate new technology in the short run and underestimate it in the long run.

智能合约现在是“阿玛拉定律”的典范,斯坦福大学计算机科学家罗伊-阿马拉(Roy Amara)认为,人类往往会在短期内高估新技术,而在长期内低估新技术。

Smart contracts maybe are not perfect. But smart contracts will only become better as technology advances, and they will become more trustworthy and efficient.

智能合约现在并不完美。但随着技术的进步,智能合约只会变得更好,它们将变得更加可信和高效。

Human mistakes will occur, whether on the blockchain or not. Coding errors or human mistakes in security (giving away your secret keys) may lead to hacking or theft.

无论是否在区块链上,或许都会出现人为错误。编码错误或安全方面的人为错误(泄露秘密密钥)可能导致黑客攻击或盗窃。

Despite human fragility, blockchain and smart contracts are likely to provide the solutions to our existing system's troubles. Blockchain technology continues to provide more security.

尽管人类很脆弱,但区块链和智能合约很可能为我们现有系统的问题提供解决方案。区块链技术将继续提供更多安全性。

Of course, no one can predict the future. We may only estimate and forecast, but we must be prepared for any scenario.

当然,没有人能预测未来。我们只能估计和预测,但我们必须为任何情况做好准备。