TLSCG: Transfer learning-based smart contract generation to empower unknown vulnerability detection in blockchain services

Author Identifier (ORCID)

Wei Ni: https://orcid.org/0000-0002-4933-594X

Abstract

Blockchains increasingly enable decentralized and trustworthy service execution. Smart contracts, i.e., self-executing programs on the blockchain, are essential for automating services. Yet, their inherent vulnerabilities can severely compromise the integrity and reliability of services. Existing detection methods are largely based on expert-defined rules, limiting their effectiveness to known vulnerability types and struggling with anomalous contracts that exhibit variant behaviors. Data imbalance further hinders the performance of deep learning-based approaches. This article presents TLSCG, a transfer learning-based framework that enhances smart contract vulnerability detection, particularly for unknown vulnerabilities, by leveraging a LSTM-based Variational Autoencoder (VAE) to enrich the training set with diverse vulnerable samples. TLSCG enhances the realism of generated contracts by incorporating a Bigram loss to preserve local semantic coherence and a Generative Adversarial Network (GAN)-based discriminator to ensure global structural consistency. Using transfer learning, the generative model can adapt to new vulnerability types, enriching training data and improving detector generalization. We further present OpTrans, a semantic- and structure-aware Transformer optimized for opcode sequence modeling. By integrating type-guided embeddings with a sparse and structure-aware attention mechanism, OpTrans effectively captures instruction semantics and execution structure. Experiments on real-world datasets show that TLSCG achieves 84% Macro-F1 in detecting unknown vulnerabilities, a 19% improvement over the state-of-the-art method Escort. Evaluations of generated samples in realism, anomalousness, and discrepancy confirm their value in improving detection.

Keywords

Smart contract, smart contract generation, transfer learning, unknown vulnerability mining

Document Type

Journal Article

Date of Publication

3-1-2026

Volume

19

Issue

2

Publication Title

IEEE Transactions on Services Computing

Publisher

IEEE

School

School of Engineering

Funders

National Natural Science Foundation of China (Grant Number: 62272031) / Beijing Nova Program (Grant Number: 20230484257) / Applied Research Program of Key Research Projects of Henan Higher Education Institutions (Grant Number: 26B520013)

Comments

Liu, C., Sui, Y., Duan, L., Ni, W., Wang, W., & Sheng, Q. Z. (2026). TLSCG: Transfer learning-based smart contract generation to empower unknown vulnerability detection in blockchain services. IEEE Transactions on Services Computing, 19(2), 1563–1576. https://doi.org/10.1109/TSC.2026.3661198

Copyright

subscription content

First Page

1563

Last Page

1576

Share

 
COinS
 

Link to publisher version (DOI)

10.1109/TSC.2026.3661198