Smart Contract Cloning Identification Using BERT Model Based Representation Learning
Abstract
The use of Smart Contracts and Blockchains has experienced a significant rise, leading to the automation of various financial and corporate operations. However, the occurrence of flaws and vulnerabilities in smart contracts has resulted in significant financial losses, raising concerns about their security. It is crucial to enhance the maintenance and reliability of smart contract codes. To detect the clones and bugs in a smart contract, in this paper, we propose a deep learning based model that learns the embedding as a continuous numeric-valued vector for each smart contract. Our approach involves five steps. First, we divide the smart contract Solidity program into streams along with their corresponding structural information. Second, we tokenize the textual data of the smart contract and create a corpus. Third, we employ the BERT word embedding model on the smart contract’s tokens corpus to learn feature representation for each token, generating a fixed-length vector of size 768. Fourth, we compute the embedding of each smart contract by considering the weighted sum of tokens within the contract. Finally, to measure clone similarity, we use hierarchical clustering on the feature vectors of smart contracts. The experimental results obtained using our approach on 22,000 Ethereum blockchain Solidity contracts show a clone ratio of 92.14%, and a precision of 93% in detecting clone-related bugs, representing significantly higher accuracy compared to conventional algorithms.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.