Semantic Code Search for Smart Contracts

11/28/2021
by   Chaochen Shi, et al.
0

Semantic code search technology allows searching for existing code snippets through natural language, which can greatly improve programming efficiency. Smart contracts, programs that run on the blockchain, have a code reuse rate of more than 90 search tools. However, the existing code search models still have a semantic gap between code and query, and perform poorly on specialized queries of smart contracts. In this paper, we propose a Multi-Modal Smart contract Code Search (MM-SCS) model. Specifically, we construct a Contract Elements Dependency Graph (CEDG) for MM-SCS as an additional modality to capture the data-flow and control-flow information of the code. To make the model more focused on the key contextual information, we use a multi-head attention network to generate embeddings for code features. In addition, we use a fine-tuned pretrained model to ensure the model's effectiveness when the training data is small. We compared MM-SCS with four state-of-the-art models on a dataset with 470K (code, docstring) pairs collected from Github and Etherscan. Experimental results show that MM-SCS achieves an MRR (Mean Reciprocal Rank) of 0.572, outperforming four state-of-the-art models UNIF, DeepCS, CARLCS-CNN, and TAB-CS by 34.2 36.8 second only to UNIF, reaching 0.34s/query.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
03/12/2021

A Multi-Modal Transformer-based Code Summarization Approach for Smart Contracts

Code comment has been an important part of computer programs, greatly fa...
research
05/31/2021

A Bytecode-based Approach for Smart Contract Classification

With the development of blockchain technologies, the number of smart con...
research
02/17/2021

AGSolT: a Tool for Automated Test-Case Generation for Solidity Smart Contracts

Blockchain and smart contract technology are novel approaches to data an...
research
03/16/2021

iContractBot: A Chatbot for Smart Contracts' Specification and Code Generation

Recently, Blockchain technology adoption has expanded to many applicatio...
research
05/04/2019

Domain Specific Code Smells in Smart Contracts

Smart contracts are programs running on a blockchain. They are immutable...
research
06/11/2021

SolcTrans: Towards machine translation of Solidity smart contract source code

Context: Decentralized applications on blockchain platforms are realized...
research
06/07/2023

Vulnerable Smart Contract Function Locating Based on Multi-Relational Nested Graph Convolutional Network

The immutable and trustable characteristics of blockchain enable smart c...

Please sign up or login with your details

Forgot password? Click here to reset