智能合約在 Nick Szabo 1994 年所提出的論文 [1] 中,被描述為”自動化執行商務上或是法律上的合約“。而在 2008 年中本聰所提出的比特幣論文 [2] 中,其區塊鏈去中心化的概念,恰好能符合要完成上述敘述所需之必要條件,即可確保不會有人能影響合約的執行。直至今日,不論產業界或是學術界,已經有越來越多區塊鏈相關的研究產出,範圍包括了整個區塊鏈的共識達成,執行效能,隱私性,經濟效益及在不同領域的應用等。除了原先的比特幣之外,也有許多為改進比特幣區塊鏈而產生的其他區塊鏈實作,其中最為人知是以太坊提供了圖靈完備的智能合約執行環境。本文將假設讀者具備基礎之區塊鏈相關知識,而將討論的重點著重於智能合約相關技術的演進。從比特幣區塊鏈上以腳本編成的智能合約,一直到利用存在性證明所做的第二層交易協定,最後以太坊將全域狀態移至虛擬環境執行。為了能夠達到共識的一致性,區塊鏈上的資訊並不完全,我們必須仰賴區塊鏈以外的系統搭成的橋樑來做鏈上鏈下的資訊交換。 在應用安全的部分,因爲區塊鏈上儲存多為高價值內容,容易成為被攻擊的對象,因此智能合約的應用需特別注重安全相關的議題。智能合約安全性問題一般而言可以分成兩類,其一是因為區塊鏈的特性,如公開,透明,及去中心化等等而衍伸需注意的安全問題。其二是和撰寫智能合約所用語言相關。
Smart contract is first mentioned from Nick Szabo’s thesis in 1994. It’s described as a self-executing and self-enforcing program. The Bitcoin, which is the first blockchain project, started at 2008 is a decentralized cash system. The concept from Bitcoin is fitted into the smart contract. Until now, more and more decentralized applications are built from smart contract in many varied areas. This paper survey different smart contract implementations from different blockchain systems, including Bitcoin script language, second layer protocol, and Ethereum smart contract. Beside the implementation methods of smart contract, the security is also important. You can find lots smart contracts that control lots fund be hacked. These issues are also mentioned and discussed in chapter 5.