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

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Zheng, Jingyi, Peng, Zifan, Liu, Yule, Wang, Junfeng, Liao, Yifan, Dong, Wenhan, He, Xinlei
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912494955528192
author Zheng, Jingyi
Peng, Zifan
Liu, Yule
Wang, Junfeng
Liao, Yifan
Dong, Wenhan
He, Xinlei
author_facet Zheng, Jingyi
Peng, Zifan
Liu, Yule
Wang, Junfeng
Liao, Yifan
Dong, Wenhan
He, Xinlei
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2507_15761
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle GasAgent: A Multi-Agent Framework for Automated Gas Optimization in Smart Contracts
Zheng, Jingyi
Peng, Zifan
Liu, Yule
Wang, Junfeng
Liao, Yifan
Dong, Wenhan
He, Xinlei
Artificial Intelligence
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.
title GasAgent: A Multi-Agent Framework for Automated Gas Optimization in Smart Contracts
topic Artificial Intelligence
url https://arxiv.org/abs/2507.15761