基于以太坊的智能合约已经广泛应用于各个领域, 然而合约开发需要完备的专业领域知识和编程能力. 针对智能合约编程友好性, 本文提出了一种对于特定领域智能合约自动生成的方法. 实现了对于智能合约的聚类分析以及交易类智能合约基本函数代码的生成, 对于生成的代码采用BLEU以及SmartCheck进行检测, 得到了较好的检测结果. 采用MFC将生成的代码和UI控件链接, 为用户提供友好的智能合约编程页面, 实现智能合约的自动生成. 方法生成的智能合约代码有一定的准确性, 能够对智能合约的开发提供帮助. 最后, 通过一个案例分析验证了生成的智能合约的可用性.
Smart contracts based on Ethereum have been widely used across various fields. The programming of smart contracts, however, requires professional developers with expertise in a special programming language; in other words, the developers must have professional domain knowledge in addition to programming ability. In this paper, a method for the automated generation of smart contracts for specific domains is proposed with the aim addressing the programming friendliness of smart contracts. The paper introduces cluster analysis of smart contracts and establishes the basic functional code for transactional type smart contracts. MFC is used to link the generated code with UI control and provide users with a friendly smart contract programming page; hence, the automatic generation of smart contracts is realized, thereby reducing the difficulty and cost of contract programming. Finally, a case study is presented to verify the availability of the generated smart contract.
[1] SWAN M. Blockchain: Blueprint for a New Economy [M]. Sebastopol, California: O’Reilly Media, 2015.
[2] 韩璇, 袁勇, 王飞跃. 区块链安全问题: 研究现状与展望 [J]. 自动化学报, 2019, 45(1): 206-225
[3] ZHENG Z, XIE S, DAI H N, et al. Blockchain challenges and opportunities [J]. International Journal of Web and Grid Services, 2018, 14(4): 352-375.
[4] SZABO N. Formalizing and securing relationships on public networks [EB/OL]. [2017-07-19]. http://www.firstmonday.org/ojs/index.php/fm/article/view/548/469.
[5] 丁亚雷. 基于长短期记忆模型的入侵检测系统的设计与实现 [D]. 南京: 东南大学, 2019.
[6] OMOHUNDRO S. Cryptocurrencies, smart contracts, and artificial intelligence [J]. AI Matters, 2014, 1(2): 19-21.
[7] ZHENG Z B, XIE S A, DAI H N, et al. An overview on smart contracts: Challenges, advances and platforms [J]. Future Generation Computer Systems, 2020, 105: 475-491.
[8] TIKHOMIROV S, VOSKRESENSKAYA E, IVANITSKIY I, et al. Smartcheck: Static analysis of ethereum smart contracts [C]// 2018 IEEE/ACM 1st International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB). Los Alamitos: IEEE, 2018: 9-16.
[9] 胡凯. 智能合约的形式化验证方法 [J]. 信息安全研究, 2016, 2(12): 1080-1089
[10] 许芳芳. 基于DBSCAN优化算法的Web文本聚类研究 [D]. 上海: 华东师范大学, 2011.
[11] JÜRGEN S. Deep learning in neural networks: An overview [J]. Neural Networks, 2015, 61: 85-117.
[12] 张孝慈. 递归神经网络模型的若干关键问题研究 [D]. 合肥: 中国科学技术大学, 2019.
[13] 郝同安. 基于神经网络的代码自动生成技术的研究与应用 [D]. 北京: 北京邮电大学, 2019.