Context: Decentralized applications on blockchain platforms are realized through smart contracts. However, participants who lack programming knowledge often have difficulties reading the smart contract source codes, which leads to potential security risks and barriers to participation. Objective: Our objective is to translate the smart contract source codes into natural language descriptions to help people better understand, operate, and learn smart contracts. Method: This paper proposes an automated translation tool for Solidity smart contracts, termed SolcTrans, based on an abstract syntax tree and formal grammar. We have investigated 3,000 smart contracts and determined the part of speeches of corresponding blockchain terms. Among them, we further filtered out contract snippets without detailed comments and left 811 snippets to evaluate the translation quality of SolcTrans. Results: Experimental results show that even with a small corpus, SolcTrans can achieve similar performance to the state-of-the-art code comments generation models for other programming languages. In addition, SolcTrans has consistent performance when dealing with code snippets with different lengths and gas consumption. Conclusion: SolcTrans can correctly interpret Solidity codes and automatically convert them into comprehensible English text. We will release our tool and dataset for supporting reproduction and further studies in related fields.
翻译:目标:我们的目标是将智能合同源代码转换成自然语言描述,以帮助人们更好地理解、操作和学习智能合同。方法:本文提出一个Solidity智能合同的自动翻译工具,称为SolocTrans。我们调查了3,000个智能合同,确定了相应链条条款的演讲部分。结论:SolcTrans可以正确解释固态代码,并自动将其转换为可理解的英文文本。结果:实验结果:即使有少量材料,SolcTrans也可以取得与其他编程语言的最新代码生成评论模型相似的性能。此外,SolcTrans在处理不同长度和气体消耗的代码片断时,其性能是一致的。结论:SolcTrans可以正确解释固态代码,并自动将其转换为可理解的英文文本。结果:实验结果显示,即使有少量材料,SolcTrans也可以实现与其他编程语言的最新代码生成模型的类似性能。此外,Solctransry在处理不同长度和气体消耗的代码片断时,其性能保持一贯性。结论:Solctrary可以正确解释固化代码,并自动将其转换成可理解的英文文本。我们将在相关领域公布工具和数据中公布。