GasAgent: A Multi-Agent Framework for Automated Gas Optimization in Smart Contracts

Jingyi Zheng, Zifan Peng, Yule Liu, Junfeng Wang, Yifan Liao +2 more
7/21/2025
cs.AI

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Smart contracts are trustworthy, immutable, and automatically executed programs on the blockchain. Their execution requires the Gas mechanism to ensure efficiency and fairness. However, due to non-optimal coding practices, many contracts contain Gas waste patterns that need to be optimized. Existing solutions mostly rely on manual discovery, which is inefficient, costly to maintain, and difficult to scale. Recent research uses large language models (LLMs) to explore new Gas waste patterns. However, it struggles to remain compatible with existing patterns, often produces redundant patterns, and requires manual validation/rewriting. To address this gap, we present GasAgent, the first multi-agent system for smart contract Gas optimization that combines compatibility with existing patterns and automated discovery/validation of new patterns, enabling end-to-end optimization. GasAgent consists of four specialized agents, Seeker, Innovator, Executor, and Manager, that collaborate in a closed loop to identify, validate, and apply Gas-saving improvements. Experiments on 100 verified real-world contracts demonstrate that GasAgent successfully optimizes 82 contracts, achieving an average deployment Gas savings of 9.97%. In addition, our evaluation confirms its compatibility with existing tools and validates the effectiveness of each module through ablation studies. To assess broader usability, we further evaluate 500 contracts generated by five representative LLMs across 10 categories and find that GasAgent optimizes 79.8% of them, with deployment Gas savings ranging from 4.79% to 13.93%, showing its usability as the optimization layer for LLM-assisted smart contract development.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{zheng2025gasagent,
  title  = {GasAgent: A Multi-Agent Framework for Automated Gas Optimization in Smart Contracts},
  author = {Jingyi Zheng and Zifan Peng and Yule Liu and Junfeng Wang and Yifan Liao and Wenhan Dong and Xinlei He},
  year   = {2025},
  eprint = {2507.15761},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2507.15761v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2507.15761.svg)](https://codeofpaper.com/paper/2507.15761)

Discussion