Journal of Computer Applications ›› 2026, Vol. 46 ›› Issue (7): 2074-2084.DOI: 10.11772/j.issn.1001-9081.2026010107

• Artificial intelligence • Previous Articles    

Smart contract generation framework driven by LLM and SWRL for cross-border data compliance across heterogeneous blockchains

Linkai ZHU1, Lu YANG1, Hongjie ZHANG1, Zijin WU2, Lu LIU3()   

  1. 1.School of Management Science and Information Engineering,Hebei University of Economics and Business,Shijiazhuang Hebei 050061,China
    2.China Electric Power Equipment and Technology Company Limited,Beijing 100052,China
    3.School of Cyber Science and Technology,Shandong University,Qingdao Shandong 266237,China
  • Received:2026-02-04 Revised:2026-03-20 Accepted:2026-04-09 Online:2026-04-23 Published:2026-07-10
  • Contact: Lu LIU
  • About author:ZHU Linkai, born in 1989, Ph. D., lecturer. His research interests include smart contract engineering, large language models.
    YANG Lu, born in 2001, M. S. candidate. His research interests include large language model agents, natural language processing.
    ZHANG Hongjie, born in 2003, M. S. candidate. His research interests include retrieval-augmented generation, large language model code generation.
    WU Zijin, born in 1989, M. S., senior engineer. His research interests include cross-border data.
  • Supported by:
    Foundation:Natural Science Foundation of Hebei Province(F2024207003);Scientific Research Project of Hebei Education Department(BJK2024111);Social Science Development Research Project of Hebei Province(HBSKFZ25YB150)

LLM与SWRL驱动的跨境数据合规异构跨链智能合约生成框架

朱林凯1, 杨璐1, 张弘杰1, 吴子衿2, 刘璐3()   

  1. 1.河北经贸大学 管理科学与信息工程学院,石家庄 050061
    2.中国电力技术装备有限公司,北京 100052
    3.山东大学 网络空间安全学院,山东 青岛 266237
  • 通讯作者: 刘璐
  • 作者简介:朱林凯(1989—),男,浙江义乌人,讲师,博士,主要研究方向:智能合约工程、大语言模型
    杨璐(2001—),男,河北石家庄人,硕士研究生,主要研究方向:大模型智能体、自然语言处理
    张弘杰(2003—),男,山西晋中人,硕士研究生,主要研究方向:检索增强生成、大语言模型代码生成
    吴子衿(1989—),男,宁夏银川人,高级工程师,硕士,主要研究方向:跨境数据
  • 基金资助:
    河北省自然科学基金资助项目(F2024207003);河北省教育厅科学研究项目(BJK2024111);河北省社会科学发展研究课题(HBSKFZ25YB150)

Abstract:

Enterprises operating across borders often face conflicting data protection regulations and must address coordinated execution across heterogeneous blockchains, making compliant cross-border data transfer complex and risky. Therefore, a smart contract generation framework driven by Large Language Model (LLM) and Semantic Web Rule Language (SWRL) was proposed for cross-border data compliance across heterogeneous blockchains. First, centering on formalized rule definition-driven access control, cross-chain interoperability between two heterogeneous blockchains was achieved by cooperating with notarization services. Additionally, the data subject's latest authorization was injected into access decisions in real-time by utilizing an integrated consent module. Second, a rule matching framework based on finite-state decision process was constructed to decompose Semantic Web Rule Language (SWRL) compliance rules into reusable and modular logical units. Finally, a fine-tuned LLM was introduced to complete the SWRL rules semantically, which were automatically converted into executable smart contract code on the blockchain. Experimental results show that in the smart contract code generation task, the fine-tuned LLM achieves a comprehensive code generation success rate (FullRate) of 76.1%, which is improved by 18.6, 3.2, and 1.2 percentage points compared to that of the baseline models LLaMA-3-8B-Instruct, DeepSeek-V3, and DeepSeek-R1, respectively. Furthermore, the performance of the prototype system was evaluated under varying network node counts and adjustable channel configurations, demonstrating that it meets enterprise-level scalability requirements. The proposed framework significantly enhances the efficiency of smart contract generation while maintaining high security and logical correctness, demonstrating the practical feasibility and engineering application value of the framework in efficient and compliant cross-border data sharing scenarios.

Key words: blockchain, data compliance, Semantic Web Rule Language (SWRL), smart contract, Large Language Model (LLM), code generation

摘要:

跨境运营的企业通常面临彼此冲突的数据保护法规,需解决异构区块链之间的协同执行问题,这使得合规的数据跨境传输变得复杂且存在风险。因此,提出一种大语言模型(LLM)与语义网规则语言(SWRL)驱动的跨境数据合规异构跨链智能合约生成框架。首先,以形式化规则定义驱动的访问控制为核心,配合公证服务实现2个异构区块链之间的跨链互操作,并利用集成的同意模块将数据主体的最新授权实时注入访问决策;其次,构建基于有限状态决策流程的规则匹配框架,将SWRL合规规则分解为可复用的模块化逻辑单元;最后,引入经微调的LLM对SWRL规则进行语义补全,并将它们自动转换为可在区块链上执行的智能合约代码。实验结果表明,在智能合约代码生成的任务中,经过微调的LLM在综合代码生成成功率FullRate上达到了76.1%,与基线模型LLaMA-3-8B-Instruct、DeepSeek-V3和DeepSeek-R1相比,分别提升了18.6、3.2和1.2个百分点;此外,对原型系统在不同网络节点数和通道数可调的条件下进行性能评估,验证了它能够满足企业级的可扩展性需求。本文框架在保持高安全性与逻辑正确性的同时,显著提升了智能合约生成的效率,在高效且合规的跨境数据共享场景下具有实际可行性与工程应用价值。

关键词: 区块链, 数据合规, 语义网规则语言, 智能合约, 大语言模型, 代码生成

CLC Number: