arXiv:2509.23976cs.LG2025-09被引 1

用强化学习自动生成省气的金融衍生品合约代码

Curriculum-Guided Reinforcement Learning for Synthesizing Gas-Efficient Financial Derivatives Contracts

  • 用PPO算法从代码库选片段,分两阶段训练:先保证正确性再优化耗气
  • 在未见数据上比基线节省最多35.59%的Gas开销
  • 适合需要高效智能合约的金融科技开发者

基于智能合约的金融衍生品自动化可大幅提升效率,但将金融规格转化为高效的可执行代码仍面临挑战。本文提出一种强化学习框架,直接从通用领域模型(CDM)规范生成功能正确且气体消耗低的Solidity智能合约。采用近端策略优化(PPO)代理,从预定义代码库中选择最优代码片段。为应对复杂搜索空间,采用两阶段课程学习:先训练代理确保功能正确性,再聚焦于气体优化。实验结果表明,该方法在未见测试数据上实现最高达35.59%的气体成本降低,优于未经优化的基线。本工作为自动合成可靠且经济可持续的智能合约提供了可行路径,弥合了高层金融协议与高效链上执行之间的鸿沟。

原文摘要 · Abstract (English)

Smart contract-based automation of financial derivatives offers substantial efficiency gains, but its real-world adoption is constrained by the complexity of translating financial specifications into gas-efficient executable code. In particular, generating code that is both functionally correct and economically viable from high-level specifications, such as the Common Domain Model (CDM), remains a significant challenge. This paper introduces a Reinforcement Learning (RL) framework to generate functional and gas-optimized Solidity smart contracts directly from CDM specifications. We employ a Proximal Policy Optimization (PPO) agent that learns to select optimal code snippets from a pre-defined library. To manage the complex search space, a two-phase curriculum first trains the agent for functional correctness before shifting its focus to gas optimization. Our empirical results show the RL agent learns to generate contracts with significant gas savings, achieving cost reductions of up to 35.59% on unseen test data compared to unoptimized baselines. This work presents a viable methodology for the automated synthesis of reliable and economically sustainable smart contracts, bridging the gap between high-level financial agreements and efficient on-chain execution.

智能合约强化学习气体优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。