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

03/12/2021
by   Zhen Yang, et al.
0

Code comment has been an important part of computer programs, greatly facilitating the understanding and maintenance of source code. However, high-quality code comments are often unavailable in smart contracts, the increasingly popular programs that run on the blockchain. In this paper, we propose a Multi-Modal Transformer-based (MMTrans) code summarization approach for smart contracts. Specifically, the MMTrans learns the representation of source code from the two heterogeneous modalities of the Abstract Syntax Tree (AST), i.e., Structure-based Traversal (SBT) sequences and graphs. The SBT sequence provides the global semantic information of AST, while the graph convolution focuses on the local details. The MMTrans uses two encoders to extract both global and local semantic information from the two modalities respectively, and then uses a joint decoder to generate code comments. Both the encoders and the decoder employ the multi-head attention structure of the Transformer to enhance the ability to capture the long-range dependencies between code tokens. We build a dataset with over 300K <method, comment> pairs of smart contracts, and evaluate the MMTrans on it. The experimental results demonstrate that the MMTrans outperforms the state-of-the-art baselines in terms of four evaluation metrics by a substantial margin, and can generate higher quality comments.

READ FULL TEXT
research
11/28/2021

Semantic Code Search for Smart Contracts

Semantic code search technology allows searching for existing code snipp...
research
03/18/2022

M2TS: Multi-Scale Multi-Modal Approach Based on Transformer for Source Code Summarization

Source code summarization aims to generate natural language descriptions...
research
06/11/2021

SolcTrans: Towards machine translation of Solidity smart contract source code

Context: Decentralized applications on blockchain platforms are realized...
research
11/03/2020

Smart-Corpus: an Organized Repository of Ethereum Smart Contracts Source Code and Metrics

Many empirical software engineering studies show that there is a great n...
research
05/25/2023

Definition and Detection of Defects in NFT Smart Contracts

Recently, the birth of non-fungible tokens (NFTs) has attracted great at...
research
11/17/2021

GN-Transformer: Fusing Sequence and Graph Representation for Improved Code Summarization

As opposed to natural languages, source code understanding is influenced...
research
09/27/2021

Improving Stack Overflow question title generation with copying enhanced CodeBERT model and bi-modal information

Context: Stack Overflow is very helpful for software developers who are ...

Please sign up or login with your details

Forgot password? Click here to reset