Optimizing Gas Consumption in Ethereum Smart Contracts: A Static Analysis Approach
Abstract
Ethereum smart contracts enable decentralized applications (dApps) on the blockchain and execution of each transaction on dApps incurs a gas cost (fee). While the gas cost prevents denial-of-service (DoS) attacks and incentivizes miners, unoptimized smart contracts may cause excessive gas waste, resulting in higher transaction costs and reduced scalability. Hence, this paper introduces four novel gas waste detectors integrated into the Slither static analysis framework to identify common gas wastes in Solidity smart contracts, including redundant use of address(this), division by unsigned integers, short constant strings, and unnecessary type casting. We analyzed 397 smart contracts from 53 dApps deployed on Ethereum, uncovering 250 instances of gas waste. Our findings indicate that every dApp analyzed exhibits at least one form of gas waste. Notably, division by unsigned integers emerged as the most prevalent gas waste, while half of the dApps could save gas by optimizing short constant strings. To facilitate further research, the annotated dataset of gas waste instances is available on GitHub.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.