Source-linked AI summary
An empirical analysis of smart contracts: platforms, applications, and design patterns
Massimo Bartoletti, Livio Pompianu
TL;DR
Smart-contract platforms have proliferated, but their practical use, security, and design remain insufficiently understood. The paper surveys platforms, quantifies Bitcoin and Ethereum contract usage by application domain, and analyzes Ethereum source-code patterns, finding category-specific pattern adoption while noting important execution limitations.
Problem
Smart contracts are increasingly used, yet their actual benefits, trustworthiness, security, and implementation practices remain insufficiently understood.
Method
The paper surveys six platforms, classifies 834 Bitcoin and Ethereum contracts by application domain, and identifies and measures nine Ethereum design patterns.
Results
Token, authorization, time-constraint, and termination patterns are generally most used, with oracle and randomness patterns associated mainly with games and token patterns mostly with financial contracts.
Takeaways & Limitations
Quantifying contract categories and recurring patterns can inform platform design and analysis techniques targeting specific smart-contract patterns.
Takeaways & Limitations
Ethereum’s practical computability is limited by transaction gas limits, and common local or off-chain randomness techniques are not generally considered secure.
Abstract
from arXiv · showhide
Smart contracts are computer programs that can be consistently executed by a network of mutually distrusting nodes, without the arbitration of a trusted authority. Because of their resilience to tampering, smart contracts are appealing in many scenarios, especially in those which require transfers of money to respect certain agreed rules (like in financial services and in games). Over the last few years many platforms 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
Smart contracts have gained attention as tamper-resistant programs for enforcing agreed rules without trusted authorities, but their benefits, security, and actual use remain insufficiently understood. This paper surveys platforms, classifies Bitcoin and Ethereum contracts by application domain, and quantitatively studies Ethereum programming patterns.
- Motivation: Smart contracts automatically enforce correct execution across mutually distrusting nodes without relying on a trusted authority.Their resilience to tampering makes them appealing where transfers of money must follow agreed rules.
- Motivation: The growing ecosystem includes more than 600 cryptocurrencies and thousands of blockchain- and smart-contract-related GitHub projects.The paper reports 2,715 blockchain projects and 445 smart-contract projects in the cited period.
- Research problem: Security and trustworthiness remain insufficiently assessed, with unsafe smart-contract design choices causing severe losses such as the DAO’s approximately 50M USD theft.The paper also notes that many other vulnerabilities have been reported since the DAO incident.
- Research problem: Understanding contract usage and implementation could guide safer domain-specific languages and improve analysis techniques by targeting recurring programming patterns.The paper frames these as potential benefits of studying actual contract designs.
- Contributions: The study examines six platforms selected from twelve identified through Web news coverage between June 2013 and September 2016.Platforms were compared mainly on usage and support for programming smart contracts.
- Contributions: The authors classify 834 Bitcoin and Ethereum contracts by application domain, compare category usage, and identify nine common Ethereum design patterns.Ethereum source-code availability enables quantitative analysis of pattern usage.
2 Platforms for smart contracts
The paper compares six publicly accessible smart-contract platforms selected from twelve candidates, emphasizing blockchain architecture, consensus, and contract languages. Bitcoin offers limited script-based contracts, whereas Ethereum provides Turing-complete contracts; other platforms vary in blockchain dependence and governance.
- Platform selection: The study selects platforms by reviewing 175 CoinDesk articles published from June 2013 through September 2016, identifying twelve candidates.The candidates include Bitcoin, Ethereum, Counterparty, Lisk, Monax, Stellar, and others.
- Platform selection: Platforms were retained only if launched, supported by a developer community, and publicly accessible for writing, testing, exploring, or running nodes.The authors inspected official and community resources for each candidate.
- Platform comparison: Bitcoin uses a public blockchain and proof-of-work consensus, while its non-Turing-complete scripting language supports only limited transaction-redemption conditions.Its scripts provide basic arithmetic, logical, and cryptographic operations.
- Platform comparison: Ethereum uses a public blockchain, a Bitcoin-like consensus algorithm, and Turing-complete bytecode, with Solidity among the high-level languages compiling to it.Users invoke contracts through blockchain transactions, and users or contracts can store and transfer ether.
- Platform comparison: Counterparty embeds contract data in Bitcoin transactions and interprets it separately, without using a consensus protocol to validate computation results.It uses the same contract language as Ethereum and has its own currency.
- Platform comparison: Monax supports Ethereum contracts on private blockchains with configurable access policies and round-based voting that confirms blocks at two-thirds of voting power.Lisk instead uses a public blockchain, delegated proof-of-stake, and JavaScript or Node.js contracts.
3 Analysing the usage of smart contracts
The paper classifies smart contracts by application domain and measures category-level usage across Bitcoin and Ethereum using a sample of 834 contracts. The analysis finds that financial contracts dominate both platforms, while transaction patterns differ substantially across other categories and platforms.
- Methodology: The study samples and classifies 834 smart contracts from Bitcoin and Ethereum by intended application domain.Ethereum contracts are manually inspected through verified Solidity source code, while Bitcoin contracts are classified using project webpages and discussion forums.
- Taxonomy: The taxonomy contains five categories: Financial, Notary, Game, Wallet, and Library.These categories cover money management, persistent data and provenance, games, blockchain interaction, and reusable general-purpose operations.
- Quantifying usage: The analysis measures category usage through transaction distributions and reports detected contracts and total transactions for Bitcoin and Ethereum.The dataset contains all transactions related to the 834 sampled contracts.
- Results: 1,673,271 transactions were analyzed, and Bitcoin contracts generated more transactions per contract despite being fewer than Ethereum contracts.In the financial category, six Bitcoin contracts account for two thirds of the transactions generated by 373 Ethereum contracts in the same category.
- Results: Both platforms focus mainly on financial contracts, but their other category patterns differ markedly.Notary transactions are similarly prominent to Financial transactions in Bitcoin, whereas Game is Ethereum’s second most used category; the study reports no experimental evidence that Bitcoin games are used in practice.
- Limitations: Some contracts cannot be categorized when project pages, forum comments, and contract-source comments provide insufficient information.This limits classification in cases where the available contextual evidence is inadequate.
4 Design patterns for Ethereum smart contracts
The paper manually inspects 811 Ethereum contracts to identify design patterns and quantify how their usage varies across contract categories. Patterns differ in prevalence and category concentration, with several patterns especially associated with financial, game, or wallet contracts.
- Method: Manual inspection of 811 Solidity contracts identifies common Ethereum design patterns and measures their usage across contract categories.The analysis first describes the patterns and then quantifies their prevalence by category.
- Pattern meanings: Tokens distribute fungible, transferable, and countable goods, while authorization restricts critical operations according to the caller address.Tokenized goods may include coins, shares, outcomes, tickets, physical property, or digital assets; authorization commonly checks whether the caller is the contract owner.
- Pattern meanings: Oracles provide external data through contract state updates because direct external queries would break deterministic execution; randomness techniques remain generally insecure.Contracts may query off-chain oracle-generated values or locally use values such as hashes of future blocks.
- Usage by category: Token, authorization, time constraint, and termination are generally the most used patterns, while oracle and randomness patterns are peculiar to game contracts and tokens mostly serve financial contracts.Termination and time constraint span several categories, whereas math appears in every category despite being less used.
- Usage by category: Financial contracts most frequently use authorization (51%), token (24%), and time constraint (23%), while 29% perform simple operations without the described patterns.The study also reports that 69% of contracts using fork check are financial, reflecting the need to identify the active blockchain branch before moving funds.
- Usage by category: 100% of wallet contracts adopt both authorization and termination, and 94% also use time constraint.Oracle, poll, and randomness patterns are of little use in wallets, while math sometimes secures balance operations.
5 Conclusions
The paper surveys smart-contract platforms and usage, then connects Ethereum design patterns with application domains to inform domain-specific languages and analysis techniques.
- The study examines six smart-contract platforms, comparing their crucial technical differences.
- 834 contracts from Bitcoin and Ethereum are categorized by application domain and measured for category relevance.
- Ethereum source-code availability enables analysis of the most common design patterns used in smart contracts.
- Correlations between design patterns and application domains can guide programming primitives in domain-specific smart-contract languages.
- The study relates to blockchain comparisons, smart-contract design patterns, and Ethereum security-analysis techniques.Its pattern analysis could help target contracts with specific programming patterns.