TLSCG: Transfer Learning-Based Smart Contract Generation to Empower Unknown Vulnerability Detection in Blockchain Services
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.
Fields of Study & Subjects
Blockchain Technology Applications and Security
Adversarial Robustness in Machine Learning
Software System Performance and Reliability
Publication details
- Journal / source
- IEEE Transactions on Services Computing
- Publisher
- Institute of Electrical and Electronics Engineers (IEEE)
- Volume
- 19
- Issue
- 2
- Pages
- 1563–1576
- Publication date
- 4 February 2026