Optimizing Gas Efficiency in Ethereum Smart Contracts Using Design Pattern Refinement and Complexity Reduction
Abstract
Smart contracts on the Ethereum blockchain enable automation and transparency in decentralized applications; however, their scalability is often constrained by high gas costs resulting from inefficient code design. This research investigates the relationship between cyclomatic code complexity and gas consumption, proposing a design pattern-based approach to optimize gas efficiency in Ethereum smart contracts. Three common Solidity patterns Factory, Registry, and State Machine were optimized using both existing and novel techniques, including variable packing, the use of fixed-size data types (uint256, bytes32), immutable variables, and mapping simplification. These optimizations were implemented and tested within a real-world coco peat supply chain management system to measure their impact on gas usage. Experimental results showed that deployment gas costs decreased by approximately 19 % and runtime execution gas by around 14 %, confirming that design-level optimization can significantly reduce costs without affecting functionality. The findings demonstrate that structured refinement of contract design can enhance scalability, making blockchainbased enterprise solutions more efficient and economically sustainable.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.