Dept. of Computer Science and Mathematics, University Of Cagliari, Cagliari, Italy.
Dept. of Economics and Business Sciences, University Of Cagliari, Cagliari, Italy.
PLoS One. 2023 Apr 12;18(4):e0281043. doi: 10.1371/journal.pone.0281043. eCollection 2023.
Smart contracts (SC) are software programs that reside and run over a blockchain. The code can be written in different languages with the common purpose of implementing various kinds of transactions onto the hosting blockchain. They are ruled by the blockchain infrastructure with the intent to automatically implement the typical conditions of traditional contracts. Programs must satisfy context-dependent constraints which are quite different from traditional software code. In particular, since the bytecode is uploaded in the hosting blockchain, the size, computational resources, interaction between different parts of the program are all limited. This is true even if the specific programming languages implement more or less the same constructs as that of traditional languages: there is not the same freedom as in normal software development. The working hypothesis used in this article is that Smart Contract specific constraints should be captured by specific software metrics (that may differ from traditional software metrics). We tested this hypothesis on 85K Smart Contracts written in Solidity and uploaded on the Ethereum blockchain. We analyzed Smart Contracts from two repositories "Etherscan" and "Smart Corpus" and we computed the statistics of a set of software metrics related to Smart Contracts and compared them to the metrics extracted from more traditional software projects. Our results show that generally, Smart Contract metrics have more restricted ranges than the corresponding metrics in traditional software systems. Some of the stylized facts, like power law in the tail of the distribution of some metrics, are only approximate but the lines of code follow a log-normal distribution which reminds us of the same behaviour already found in traditional software systems.
智能合约(SC)是驻留在区块链上并在其上运行的软件程序。代码可以用不同的语言编写,其共同目的是将各种类型的交易实施到托管区块链上。它们受区块链基础设施的规则约束,旨在自动实现传统合约的典型条件。程序必须满足与上下文相关的约束条件,这些约束条件与传统软件代码有很大的不同。特别是,由于字节码被上传到托管区块链中,程序的大小、计算资源以及程序各部分之间的交互都受到限制。即使特定编程语言实现的结构与传统语言的结构或多或少相同:与正常软件开发相比,也没有相同的自由度。本文使用的工作假设是,智能合约的特定约束条件应该由特定的软件指标(可能与传统软件指标不同)来捕获。我们在以太坊区块链上上传的 85K 个 Solidity 编写的智能合约上测试了这个假设。我们分析了来自“Etherscan”和“Smart Corpus”两个存储库的智能合约,并计算了一组与智能合约相关的软件指标的统计数据,并将其与从更传统的软件项目中提取的指标进行了比较。我们的结果表明,一般来说,智能合约的指标比传统软件系统中的相应指标的范围更受限制。一些风格化的事实,如某些指标分布的尾部的幂律,只是近似的,但代码行数遵循对数正态分布,这让我们想起了在传统软件系统中已经发现的相同行为。