Nowadays, blockchain technologies are increasingly adopted for different purposes and in different application domains. Accordingly, more and more applications are developed for running on a distributed ledger technology (i.e.,dApps ) . The business logic of a dApp (or part of it) is usually implemented within one (or more) smart contract(s) developed through Solidity, an object-oriented programming language for writing smart contracts on different blockchain platforms, including the popular Ethereum. In Ethereum, once compiled, the smart contracts run on the machines of miners who can earn Ethers (a cryptographic currency like Bitcoin) by contributing their computing resources and thegas (in Ether) corresponds to the execution fee compensating such computing resources. However, the deployment and execution costs of a smart contract strictly depend on the  choices done by developers while implementing it . Unappropriated design choices -- e.g., in the data structures and the specific instructions used -- could lead to higher gas consumption than necessary. In this paper, we systematically identify a set of 20 Solidity code smells that could affect the deployment and transaction costs of a smart contract, i. e.,\textit{cost smells . On top of these smells, we propose GasMet, a suite of metrics for statically evaluating the code quality of a smart contract , from the gas consumption perspective. In an experiment involving 2,186 real-world smart contracts , we demonstrate that the proposed metrics (i) have direct associations with deployment costs , and (ii) they could be used to properly identify the level of gas consumption of a smart contract without the need for deploying it .
Nowadays, more and more applications are developed for running on a distributed ledger technology , namely dApps . The business logic of dApps is usually implemented within smart contracts developed through Solidity, a programming language for writing smart contracts on different blockchain platforms, including the popular Ethereum. In Ethereum, the smart contracts run on the machines of miners and the gas corresponds to the execution fee compensating such computing resources. However, the deployment and execution costs of a smart contract depend on the implementation choices done by developers . Unappropriated design choices could lead to higher gas consumption than necessary. In this paper, we (i) identify a set of 19 Solidity code smells affecting the deployment and transaction costs of a smart contract, \textit{ and (ii) assess the relevance of such smells through a survey involving 34 participants. On top of these smells, we propose GasMet, a suite of metrics for statically evaluating the code quality of a smart contract from the gas consumption perspective. An experiment involving 2,186 smart contracts demonstrates that the proposed metrics have direct associations with deployment costs . The metrics in our suite can be used for more easily identifying source code segments that need optimizations .
D
blockchain technologies are increasingly adopted for different purposes and in different application domains. Accordingly,
D
(i.e.,
D
dApps
R
)
, namely dApps
R
a dApp (or part of it)
dApps
R
one (or more) smart contract(s)
smart contracts
R
an object-oriented
a
D
once compiled,
D
who can earn Ethers (a cryptographic currency like Bitcoin) by contributing their computing resources and the
D
gas
R
(in Ether)
and the gas
D
strictly
A
implementation
D
while implementing it
D
-- e.g., in the data structures and the specific instructions used --
R
systematically
(i)
R
20
19
R
that could affect
affecting
D
i. e.,
D
cost smells
R
.
and (ii) assess the relevance of such smells through a survey involving 34 participants.
D
,
R
In an
An
R
real-world smart contracts , we demonstrate
smart contracts demonstrates
D
(i)
R
, and (ii) they could be used to properly identify the level of gas consumption of a smart contract without the need for deploying it
. The metrics in our suite can be used for more easily identifying source code segments that need optimizations