没有合适的资源?快使用搜索试试~ 我知道了~
智能合约的实证分析:平台,应用程序和设计模式1
需积分: 0 0 下载量 111 浏览量
2022-08-03
17:19:55
上传
评论
收藏 222KB PDF 举报
温馨提示
试读
16页
智能合约的实证分析:平台,应用程序和设计模式1
资源详情
资源评论
资源推荐
arXiv:1703.06322v1 [cs.CR] 18 Mar 2017
An empirical analysis of smart contracts:
platforms, applications, and design patterns
Massimo Bartoletti and Livio Pompianu
Universit`a degli Studi di Cagliari, Cagliari, Italy
{bart,livio.pompianu}@unica.it
Abstract. Smart contracts are computer programs that can be consis-
tently executed by a network of mutually distrusting nodes, without the
arbitration of a trusted authority. Because of their resilience to tamp er-
ing, smart contracts are appealing in many scenarios, especially in those
which require transfers of money to respect certain agreed rules (like
in financial serv ices and in games). Over the last few years many plat-
forms for smart contracts have been proposed, and some of them have
been actually implemented and used. We study how the notion of smart
contract is interpreted in some of these platforms. Focussing on the two
most widespread ones, Bitcoin and Ethereum, we quantify the usage of
smart contracts in relation to their application domain. We also analyse
the most common programming patterns in Ethereum, where the source
code of smart contracts is available.
1 Introduction
Since the release of Bitcoin in 2009 [
40], the idea of exploiting its enabling tech-
nology to develop applications beyond currency has been receiving increasing
attention [26]. In par ticular, the public and append- only ledger of transaction
(the blockchain) and the decentralized conse nsus protoc ol that Bitcoin nodes
use to e xtend it, have revived Nick Sz abo’s idea o f smart contracts — i.e. pro-
grams whose correct execution is automatically enforced without relying on
a trusted authority [
47]. The archetypal implementation of smart contra c ts is
Ethereum [28], a platform where they are rendered in a Turing-complete lan-
guage. The consensus protocol of Ethereum ensures that all and only the valid
updates to the contract states are recorded on the blockchain, so ensuring their
correct execution.
Besides Bitcoin and Ethereum, a remarkable number of alternative platforms
have flourished over the last few years, either implementing crypto-currencies
or some forms of smart contracts [
1, 7, 9, 30, 37]. For instance, the number of
crypto-currencies hosted on
coinmarketcap.com has increased from 0 to more
than 600 since 2012; the number of github projects related to blockchains and
smart contracts has reached, respectively, 2, 715 and 445 units (see Figure
1).
In the meanwhile, ICT companies and some national governments have started
dealing with these topics [41, 48], also with significant investments.
2 Bartoletti M., Pompianu, L.
05.2013
12.2013
06.2014
01.2015
07.2015
01.2016
07.2016
01.2017
0
200
400
600
Time interval
Number of currencies
Crypto-Currencies
01.2012
07.2012
02.2013
08.2013
03.2014
09.2014
04.2015
11.2015
05.2016
12.2016
0
50
100
150
200
250
Time interval
Number of projects
Blockchain
Smart Contract
Fig. 1: On the left, monthly trend of the number of crypto-Currencies hosted on
coinmarketcap.com. On the right, number of new projects r e lated to blockchains
and smart contracts which are created every month on github.com.
Despite the growing hype on blockchains and sma rt contracts, the under-
standing of the actual benefits of thes e technolo gies, and of their trustworthiness
and secur ity, has still to be ass essed. In particular, the consequences of unsafe
design choices for the programming languages for smart contracts c an be fatal, as
witnessed by the unfortunate epilogue of the DAO c ontract [13], a crowdfunding
service plundered of ∼ 50M USD because of a pr ogramming error. Since then,
many other vulner abilities in smart contract have been reported [
12, 14, 18, 37].
Understanding how smart contracts are used and how they are implemented
could help designers of s mart contract platforms to create new domain-specific
languages (not necessarily Turing c omplete [
27,29,33,42]), which by-design avoid
vulnerabilities as the ones discussed above. Further, this knowledge could help
to improve analysis techniques for smart contracts (like e.g. the ones in [
25,37]),
by targeting contr acts with specific programming patterns.
Contributions. This paper is a methodic survey on smart contracts, with a
focus on Bitcoin and Ether eum — the two most widespread platforms currently
supporting them. Our main contributions can be s umma rised as follows:
– in Section 2 we examine the Web for news about smart contracts in the
period from June 2013 to September 2016, collecting data about 12 plat-
forms. We choose from them a sample of 6 platforms which are amenable
to analy tical investigation. We analyse and compare several aspects of the
platforms in this sample, mainly concerning their usage, and their support
for programming smart contracts.
– in Section
3 we propose a taxonomy of smart contracts, sorting them into cat-
egories which reflect their application domain. We collect from the blockchains
of Bitco in and Ethereum a sample of 83 4 smart co ntracts, which we classify
according to our taxono my. We then study the usage of smart contracts,
measuring the distribution of their transactions by category. This a llows us
An empirical analysis of smart contracts 3
to c ompare the different usage of Bitcoin and Ethereum as platforms for
smart contracts.
– in Section
4 we consider the source code of the Ether eum contracts in our
sample. We identify 9 common design patterns, and we quantify their usage
in contracts, also in relation to the associated category. Together with the
previous point, ours constitutes the first quantitative investigation on the
usage and programming of smart contract in Ethereum.
All the data collec ted by our survey are availble online at: goo.gl/pOswL8.
2 Platforms for smart contracts
In this section we analyse various platforms for smart contracts. We start by
presenting the methodology we have followed to choos e the candidate platforms
(Section 2.1). Then we describe the key features of each platform, pinpointing
differences and similarities, and drawing some general statistics (Section 2.2).
2.1 Methodology
To choose the platforms subject of our study, we have drawn up a candidate
list by examining all the articles of
coindesk.com in the “smart contracts” cat-
egory
1
. Starting from June 2013, when the first article appeared, up to the 15th
of September 2016, 175 articles were published, describing projects, events, com-
panies and technologies related to smart contracts and blockchains. By manually
insp ecting all these articles, we have found references to 12 platforms: Bitcoin,
Codius, Counterparty, DAML, Dogeparty, Ethereum, Lisk, Monax, Roo ts tock,
Symbiont, Stellar, and Tezos.
We have then excluded from our sample the platforms which, at the time
of writing, do not satisfy one of the fo llowing criteria: (i) have already been
launched, (ii) are running a nd supported from a community of developers, and (iii)
are publicly accessible. For the last point we mean that, e.g., it must be possible
to write a contract and test it, or to e xplore the blockchain through some tools,
or to run a node. We have inspected each of the candidate platforms, ex amining
the related resources available online (e.g., official websites , white-papers, forum
discussions, etc.) After this phase, we have removed 6 platforms from our list:
Tezos and Roo tstock, as they do not satisfy condition
(i); Codius and Dogeparty,
which violate condition
(ii), DAML and Symbiont, which violate (iii). Summing
up, we have a sample of 6 platforms: Bitcoin, Ethereum, Counterparty, Stellar,
Monax and Lisk, which we discuss in the following.
2.2 Analysis of platforms
We now describe the general features of the collected platforms, focussing on:
(i) whether the platform has its own blockchain, or if it just piggy-backs on an
1
http://www.coindesk.com/category/technology/smart-contracts-news
4 Bartoletti M., Pompianu, L.
already existing one; (ii) for platforms with a public blo ckchain, their consensus
protocol, and whether the blockchain is public or private to a specific set o f
nodes; (iii) the languages used to write sma rt contracts.
Bitcoin [
40] is a platform for transferring digital currency, the bitcoins (BTC).
It has been the first decentralized cryptocurrency to be created, and now is
the one with the largest market capitalization. The platform relies on a public
blockchain to record the co mplete history of currency transactions. The nodes
of the Bitco in network use a consensus algorithm based moderately hard “proof-
of-work” puzzles to establish how to append a new blo ck of transactions to the
blockchain. Nodes work in competition to generate the next block of the chain.
The first node that solves the puzzle earns a reward in BTC.
Although the main goal of Bitcoin is to transfer currency, the immutability
and op enness of its blockchain have inspired the development of protocols that
implement (limited forms of) smart contracts. Bitcoin features a no n-Turing
complete scr ipting language, which allows to specify under which conditions a
transaction can be redeemed. The scripting language is quite limited, as it only
features so me basic arithmetic, logical, and crypto operations (e.g., hashing and
verification of digital signatures). A further limitation to its expressiveness is
the fact that only a small fraction of the nodes of the Bitcoin network processes
transactions whose script is more complex than verifying a signature
2
.
Ethereum [
28] is the second platform for market capitalization, a fter Bitcoin.
Similarly to Bitcoin, it relies on a public blockchain, with a consensus algorithm
similar to that of Bitcoin
3
. Ethereum has its own currency, caller ether (ETH).
Smart contracts ar e written in a stack-based bytecode language [49], which is
Turing-complete, unlike Bitcoin’s. There also exist a few high level languages
(the most pr ominent being Solidity
4
), which compile into the bytecode language.
Users cre ate contracts and invoke their functions by sending transactions to the
blockchain, whose effects a re validated by the network. Both users and contracts
can store money and send/receive ETH to other contracts or users.
Counterparty [
32] is a platform without its own blockchain; rather, it embeds
its data into B itcoin transactions. While the nodes of the Bitcoin networ k ignore
the data e mbedded in these tra nsactions, the nodes of Counter party recognise
and interpret them. Smart contracts can be written in the same language use d
by Ethereum. However , unlike Ethereum, no consensus protocol is used to val-
idate the results of computations
5
. Counterparty has its own currency, which
can be trans ferred between users, and be spent for exe cuting contracts. Unlike
2
As far as we know, currently only the Eligius mining pool accepts more general
transactions (called non-standard in the Bitcoin community). However, this pool
only mines ∼ 1% of the total mined blocks [
20].
3
The consensus mechanism of Ethereum is a variant of the GHOST protocol in [
46].
4
Solidity:
http://solidity.readthedocs.io/en/develop/index.html
5
See FAQ: How do Smart Contracts “form a consensus” on Counterparty?
http://counterparty.io/docs/faq-smartcontracts/#how-do-smart-contracts-form-a-consensus-on-counter
剩余15页未读,继续阅读
查理捡钢镚
- 粉丝: 21
- 资源: 317
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0