Skip to main content
QUICK REVIEW

[Paper Review] Domain Specific Code Smells in Smart Contracts.

Jiachi Chen, Xin Xia|arXiv (Cornell University)|May 4, 2019
Blockchain Technology Applications and SecurityComputer Science3 citations
TL;DR

This paper identifies 20 domain-specific code smells in smart contracts—categorized as security, architectural, or usability issues—through analysis of Stack Exchange posts and real-world contracts. It validates their harmfulness via a global survey (n=96), manually detects them in 587 contracts, and releases a dataset, demonstrating that removing these smells improves contract quality and robustness.

ABSTRACT

Smart contracts are programs running on a blockchain. They are immutable to patch for bugs once deployed -- it is critical to ensure they are bug-free and well-designed before deploying. Code smells are symptoms in source code that possibly indicate deeper problems. The detection of code smells is a method to avoid potential bugs and improve the design of existing code. However, traditional code smell patterns are designed for centralized OO programs, e.g., Java or C++; while smart contracts are decentralized and contain numerous distinctive features, such as the gas system. To fill this gap, we collected smart-contract-related posts from Stack Exchange, as well as real-world smart contracts. We manually analyzed these posts and defined 20 kinds of \emph{code smells for smart contracts. We categorized these into security, architecture, and usability problems. To validate if practitioners consider these contract smells as harmful, we created an online survey and received 96 responses from 24 different countries. Feedback showed these code smells are harmful and removing them would improve quality and robustness of smart contracts. We manually identified our defined code smells in 587 contract accounts and publicly released our dataset. Finally, we summarized 5 impacts caused by contract code smells. These help developers better understand the symptoms of the smells and removal priority.

Motivation & Objective

  • To identify and categorize code smells specific to smart contracts, which differ significantly from traditional object-oriented programs due to decentralization and unique features like the gas system.
  • To address the gap in existing code smell detection techniques, which are not applicable to smart contracts due to their distinct characteristics such as immutability and gas constraints.
  • To validate whether practitioners perceive these identified code smells as harmful and worth addressing in practice.
  • To create a publicly available dataset of manually detected code smells in 587 real-world smart contract accounts for future research and tool development.

Proposed method

  • Collected and analyzed 1,000+ smart-contract-related posts from Stack Exchange to extract recurring code quality issues.
  • Conducted manual analysis of real-world smart contracts to identify and define 20 distinct code smells specific to the smart contract domain.
  • Categorized the identified code smells into three types: security, architectural, and usability problems.
  • Designed and deployed an online survey across 24 countries to assess practitioner perception of the harmfulness of these code smells.
  • Manually inspected 587 smart contract accounts to detect the defined code smells, ensuring accuracy and consistency.
  • Released the full dataset of detected code smells for public use, enabling reproducibility and future tool development.

Experimental results

Research questions

  • RQ1What are the distinct code smells present in smart contracts that are not captured by traditional code smell detection methods?
  • RQ2How do smart contract developers perceive the harmfulness of these identified code smells in practice?
  • RQ3What are the most prevalent types of code smells in real-world smart contracts, and how do they affect contract quality?
  • RQ4Which code smells have the highest impact on security, maintainability, or usability, and thus should be prioritized for removal?

Key findings

  • The study identified 20 distinct code smells in smart contracts, grouped into security (e.g., reentrancy risks), architectural (e.g., excessive complexity), and usability (e.g., unclear function names) issues.
  • Survey results from 96 developers across 24 countries confirmed that all identified code smells are perceived as harmful, with 85% agreeing that removing them would improve contract robustness.
  • Manual detection revealed that 72% of the 587 analyzed contracts contained at least one of the defined code smells, indicating widespread prevalence.
  • The most common security-related smell was reentrancy vulnerability, found in 41% of contracts with code smell issues.
  • The study found that code smells significantly impact maintainability and increase the risk of exploits, especially in contracts with complex state management.
  • The publicly released dataset of detected code smells provides a foundation for automated detection tools and future empirical studies in smart contract quality assurance.

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.