A novel method using LSTM-RNN to generate smart contracts code templates for improved usability

Hao, Zhihao
DOI: https://doi.org/10.1007/s11042-023-14592-x
IF: 2.577
2023-04-07
Multimedia Tools and Applications
Abstract:Recently, the development of blockchain technology has given us an opportunity to improve the security and trustworthiness of multimedia. With the applications of blockchain technology, smart contracts have been widely used in many industries. However, the current development of smart contracts faces many challenges. One of the challenges is that the coding process is complicated for developers, leading to unnormalized code and can cause development and maintenance issues. Also, this is an important limitation factor in the development of smart contracts. To solve this problem, this paper proposes a method of generating contract templates based on the Long Short-Term Memory Recurrent Neural Network (LSTM-RNN) to simplify the coding process. First, the contracts available online were crawled, before detecting the vulnerabilities of these contracts. Contracts with less vulnerabilities are used as training data. For better generation effects, the Syntax Tree (AST) and the word2vec are used to extract the lexical unit sequence features to obtain a word vector in order to analyze the semantics of the code. Afterwards, the generated sequence vector features are fed to LSTM-RNN for template generation. The efficiency of four types of vectorization method models were tested and the results showed that the Skip-Gram+ HS used in this paper achieved the highest performance. In addition, a security test was conducted based on the contracts before and after using the contract templates for normalized coding. The results show that the proposed method is not only a beneficial attempt to combine deep learning with blockchain technology, but also provides an effective guidance for improving the security of smart contracts.
computer science, information systems, theory & methods,engineering, electrical & electronic, software engineering
What problem does this paper attempt to address?