Skip to content
Open access

GasGAT: a graph attention network framework for smart contract gas optimization

Sep 2026 · Frontiers in Blockchain · 0 citations · 29 references

Abstract

The optimization of gas consumption in Ethereum smart contracts is critical for enhancing the economic viability, scalability, and security of blockchain applications. Existing tools, however, are largely limited to static heuristics or local pattern matching, failing to capture the complex, non-local dependencies that drive gas inefficiency. To address this limitation, this paper introduces GasGAT, a deep learning framework that models smart contracts as semantic graphs and leverages a Graph Attention Network (GAT) to detect gas-intensive code patterns. By capturing intricate dependencies between functions, state variables, and control flows, GasGAT is able to identify non-local and inter-procedural inefficiencies that are often missed by rule-based or purely local static analysis tools. Unlike existing approaches, which focus primarily on local code patterns or rule-based detection, GasGAT explicitly reasons about long-range execution paths within smart contracts. We evaluate our method on a dataset of 40,000 verified Ethereum smart contracts (Solidity ≥0.8.0, labeled via Slither static analysis), including both a polarized subset (excluding ambiguous cases) and a full, non-filtered setting. Under 5-fold cross-validation, GasGAT achieves an accuracy of 94.92% (±1.04%) and a macro F1-score of 88.69% (±2.70%), with a McNemar statistic of 633.12 (p ≪ 0.05) confirming statistical significance. Crucially, GasGAT is the only model whose performance remains stable when correlated node features are removed (Δ = 0.00%), demonstrating that its attention mechanism learns genuine structural patterns rather than label-feature correlations. The primary contribution of GasGAT lies not in marginal accuracy improvements, but in its ability to provide interpretable, structural insights through attention mechanisms. This represents a paradigm shift from traditional detection methods toward explainable, graph-based reasoning for gas optimization, enabling developers to design more efficient, scalable, and secure decentralized applications.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.