# RAGas: Retrieval-Augmented Gas Optimization for Smart Contracts with Continuous Knowledge Integration

arXiv: https://arxiv.org/abs/2608.15857 · HTML: https://mlsanity.com/paper/2608.15857/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Placed in Privacy and security of RAG, one of 15 directions in Retrieval-augmented generation.
- Builds on 37 of its 69 references that are in the map.
- First posted on arXiv 16 Aug 2026.

## Placed in

- Retrieval-augmented generation / [Privacy and security of RAG](https://mlsanity.com/rag/privacy-and-security-of-rag/)

## Builds on (most cited first, 30 of 37)

- [Attention Is All You Need](https://mlsanity.com/paper/1706.03762/) (2017)
- [The Llama 3 Herd of Models](https://mlsanity.com/paper/2407.21783/) (2024)
- [A Survey on LLM-as-a-Judge](https://mlsanity.com/paper/2411.15594/) (2024)
- [Siren's Song in the AI Ocean: A Survey on Hallucination in Large Language Models](https://mlsanity.com/paper/2309.01219/) (2023)
- [Automatic Chain of Thought Prompting in Large Language Models](https://mlsanity.com/paper/2210.03493/) (2022)
- [Large Language Models Struggle to Learn Long-Tail Knowledge](https://mlsanity.com/paper/2211.08411/) (2022)
- [A Survey on RAG Meeting LLMs: Towards Retrieval-Augmented Large Language Models](https://mlsanity.com/paper/2405.06211/) (2024)
- [Chain of Thoughtlessness? An Analysis of CoT in Planning](https://mlsanity.com/paper/2405.04776/) (2024)
- [A Comprehensive Survey of Hallucination in Large Language, Image, Video and Audio Foundation Models](https://mlsanity.com/paper/2405.09589/) (2024)
- [Slither: A Static Analysis Framework For Smart Contracts](https://mlsanity.com/paper/1908.09878/) (2019)
- [Large Language Model (LLM) for Telecommunications: A Comprehensive Survey on Principles, Key Techniques, and Opportunities](https://mlsanity.com/paper/2405.10825/) (2024)
- [GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysis](https://mlsanity.com/paper/2308.03314/) (2023)
- [LLMs are Also Effective Embedding Models: An In-depth Overview](https://mlsanity.com/paper/2412.12591/) (2024)
- [In Search of the Long-Tail: Systematic Generation of Long-Tail Inferential Knowledge via Logical Rule Guided Search](https://mlsanity.com/paper/2311.07237/) (2023)
- [Unveiling Decentralization: A Comprehensive Review of Technologies, Comparison, Challenges in Bitcoin, Ethereum, and Solana Blockchain](https://mlsanity.com/paper/2404.04841/) (2024)
- [Interaction-Aware Vulnerability Detection in Smart Contract Bytecodes](https://mlsanity.com/paper/2410.20712/) (2024)
- [Static Application Security Testing (SAST) Tools for Smart Contracts: How Far Are We?](https://mlsanity.com/paper/2404.18186/) (2024)
- [Exploring Vulnerabilities and Concerns in Solana Smart Contracts](https://mlsanity.com/paper/2504.07419/) (2025)
- [Knowledge is Not Enough: Injecting RL Skills for Continual Adaptation](https://mlsanity.com/paper/2601.11258/) (2026)
- [Defensible Design for OpenClaw: Securing Autonomous Tool-Invoking Agents](https://mlsanity.com/paper/2603.13151/) (2026)
- [STAN: Towards Describing Bytecodes of Smart Contract](https://mlsanity.com/paper/2007.09696/) (2020)
- [How to Save My Gas Fees: Understanding and Detecting Real-world Gas Issues in Solidity Programs](https://mlsanity.com/paper/2403.02661/) (2024)
- [Bridging External and Parametric Knowledge: Mitigating Hallucination of LLMs with Shared-Private Semantic Synergy in Dual-Stream Knowledge](https://mlsanity.com/paper/2506.06240/) (2025)
- [DoS Attacks and Defense Technologies in Blockchain Systems: A Hierarchical Analysis](https://mlsanity.com/paper/2507.22611/) (2025)
- [Blockchain security based on cryptography: a review](https://mlsanity.com/paper/2508.01280/) (2025)
- [Penetrating the Hostile: Detecting DeFi Protocol Exploits through Cross-Contract Analysis](https://mlsanity.com/paper/2511.00408/) (2025)
- [CKG-LLM: LLM-Assisted Detection of Smart Contract Access Control Vulnerabilities Based on Knowledge Graphs](https://mlsanity.com/paper/2512.06846/) (2025)
- [DApps Ecosystems: Mapping the Network Structure of Smart Contract Interactions](https://mlsanity.com/paper/2401.01991/) (2024)
- [Implementation and Security Analysis of Cryptocurrencies Based on Ethereum](https://mlsanity.com/paper/2504.21367/) (2025)
- [A Comprehensive Study of Exploitable Patterns in Smart Contracts: From Vulnerability to Defense](https://mlsanity.com/paper/2504.21480/) (2025)

## Abstract (arXiv)

Ethereum is now integral to mission-critical sectors, including finance, healthcare, and supply chain management. Execution fees, commonly referred to as Gas, scale with the computational complexity of their functions. Smart contracts on Ethereum incur execution fees, known as Gas, which increase with computational complexity. Thus, optimizing Gas-intensive code while preserving functional equivalence significantly lowers deployment costs. No existing system continuously exploits evolving Gas usage patterns. We systematically analyze syntactic and semantic constructs that drive excessive Gas use. This yields six high-level categories covering twelve fine-grained antipatterns underpinning a curated knowledge base. We operationalize these insights with RAGas, a three-stage retrieval-augmented generation framework that uses a large language model to pinpoint and automatically fix Gas inefficiencies. Experiments on deployed contracts demonstrate that RAGas reduces Gas usage by up to 11% and achieves high precision and recall in detecting code snippets exhibiting Gas wastage.
