Skip to main content
QUICK REVIEW

[Paper Review] Smart Contracts Software Metrics: a First Study

Roberto Tonelli, Giuseppe Destefanis|arXiv (Cornell University)|Feb 5, 2018
Blockchain Technology Applications and SecurityComputer Science15 citations
TL;DR

This study analyzes software metrics from over 12,000 Ethereum smart contracts written in Solidity to assess whether their statistical properties differ from traditional software systems due to blockchain constraints. The key finding is that smart contract metrics exhibit significantly restricted value ranges and are better described by lognormal distributions—especially lines of code—compared to the fat-tailed power laws common in traditional software, indicating strong influence from blockchain resource limitations.

ABSTRACT

Smart contracts (SC) are software codes which 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 and work in order to satisfy conditions typical of traditional contracts. The software code must satisfy constrains strongly context dependent which are quite different from traditional software code. In particular, since the bytecode is uploaded in the hosting blockchain, size, computational resources, interaction between different parts of software are all limited and even if the specific software languages implement more or less the same constructs of traditional languages there is not the same freedom as in normal software development. SC software is expected to reflect these constrains on SC software metrics which should display metric values characteristic of the domain and different from more traditional software metrics. We tested this hypothesis on the code of more than twelve thousands SC written in Solidity and uploaded on the Ethereum blockchain. We downloaded the SC from a public repository and computed the statistics of a set of software metrics related to SC and compared them to the metrics extracted from more traditional software projects. Our results show that generally Smart Contracts metrics have ranges more restricted 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 of the same behavior already found in traditional software systems.

Motivation & Objective

  • To investigate whether smart contract software metrics display distinct statistical properties compared to traditional software due to blockchain-specific constraints.
  • To assess the impact of resource limitations—such as size, computational cost, and immutability—on metric distributions in smart contracts.
  • To compare the distribution patterns of smart contract metrics (e.g., lines of code, functions, bytecode) with those in traditional software systems.
  • To evaluate whether metrics like LOC, ABI, and bytecode follow known statistical distributions such as power laws or lognormal distributions.
  • To determine if smart contract development practices result in outlier-free, tightly bounded metric distributions due to deployment and execution constraints.

Proposed method

  • Collected and analyzed source code, ABI, and bytecode from over 12,000 smart contracts deployed on the Ethereum blockchain.
  • Computed standard software metrics including lines of code (LOC), functions, comments, cyclomatic complexity, and contract size.
  • Applied statistical fitting techniques to test for lognormal and power law distributions across metric distributions.
  • Used R² values to assess goodness-of-fit for lognormal and power law models, particularly focusing on bulk and tail regions.
  • Compared metric distributions of smart contracts with those from traditional software systems to identify domain-specific differences.
  • Analyzed the impact of blockchain constraints (e.g., immutability, gas costs) on metric variability and distribution shape.

Experimental results

Research questions

  • RQ1Do smart contract software metrics exhibit statistical distributions that differ from those in traditional software systems?
  • RQ2To what extent do blockchain constraints such as immutability and gas costs limit the range of metric values in smart contracts?
  • RQ3Which statistical distribution—lognormal or power law—best fits the distribution of smart contract metrics like lines of code and functions?
  • RQ4Are there significant outliers or fat tails in smart contract metric distributions, as seen in traditional software?
  • RQ5How do ABI and bytecode sizes compare across smart contracts, and do they follow a bell-shaped or heavy-tailed distribution?

Key findings

  • The lines of code (LOC) metric in smart contracts shows a lognormal distribution with an R² value greater than 0.98, closely matching traditional software systems.
  • Most smart contract metrics, including functions, blanks, and events, exhibit restricted value ranges due to blockchain resource constraints, with no significant outliers or fat tails.
  • The power law model provided a better fit for the tail of some distributions, but the lognormal distribution better explained the bulk of the data for most metrics, especially LOC.
  • Metrics like Comments, Address, Cyclomatic Complexity, and ABI showed poor lognormal fit in the tail, indicating upper bounds limit their maximum values.
  • Mapping and Modifier metrics were better explained by a power law in the bulk, not a lognormal, suggesting different underlying structural patterns.
  • Bytecode and ABI metrics showed initial overlap with lognormal curves but dropped faster empirically, indicating truncation due to deployment constraints.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.