Research Article

LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection

Volume: 9 Number: 5 October 30, 2026
EN

LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection

Abstract

Smart contracts play a vital role in blockchain technology, but are vulnerable to security risks due to inadequate semantic representations of their source code. Current transformer-based approaches such as BERT, CodeBERT and CodeT5 excel in lexical and contextual understanding. However, they operate mainly at the token level. This limitation prevents the capture of relationships across multiple source code lines or functions. For instance, BERT and CodeBERT are restricted to 512 tokens, thereby causing truncation of longer sequences, loss of long-range dependencies and reduced vulnerability detection accuracy in complex contracts. To address these, we propose a Line-of-Code (LoC)-based embedding approach, treating each line as a separate entity to preserve program structure. Each line is encoded using CodeBERT, and embeddings are aggregated using summation pooling to retain global context. Experiments on the SmartBugs Solidity dataset validate the effectiveness of the approach. LoC embeddings improve clustering performance, increasing Silhouette Score to 0.0888 from 0.0252 and reducing Davies-Bouldin Index to 2.9521 from 5.2315. Vulnerability detection experiments achieved classification accuracy of 96.2%, outperforming token-level approaches at 87.3%. The proposed approach improves interpretability, scalability and vulnerability detection. Future research should explore larger datasets and additional blockchain codebases. These directions will strengthen robustness, performance and generalization capabilities.

Keywords

Ethical Statement

The authors declare that all scientific and ethical principles were strictly followed during the preparation of this study. All sources consulted and utilized have been appropriately acknowledged and cited in the bibliography.

References

  1. N. A. Gupta, M. Bansal, S. Sharma, D. Mehrotra, and M. Kakkar, “Detection of vulnerabilities in blockchain smart contracts using deep learning,” Wireless Networks, vol. 31, no. 1, pp. 201–217, 2025, doi: 10.1007/s11276-024-03755-9.
  2. J. Yang, S. Liu, S. Dai, Y. Fang, K. Xie, and Y. Lu, “ByteEye: A smart contract vulnerability detection framework at bytecode level with graph neural networks,” Automated Software Engineering, vol. 33, no. 1, pp. 1–38, 2026.
  3. R. Agarwal, T. Thapliyal, and S. K. Shukla, “Vulnerability and transaction behavior based detection of malicious smart contracts,” in International Symposium on Cyberspace Safety and Security. Springer, 2021, pp. 79–96.
  4. T. Alladi, V. Chamola, R. M. Parizi, and K.-K. R. Choo, “Blockchain applications for industry 4.0 and industrial IoT: A review,” IEEE Access, vol. 7, pp. 176 935–176 951, 2019, doi: 10.1109/ACCESS.2019.2956748.
  5. J. F. Ferreira, P. Cruz, T. Durieux, and R. Abreu, “SmartBugs: A framework to analyze Solidity smart contracts,” in Proceedings of the 35th IEEE/ACM international conference on automated software engineering, 2020, pp. 1349–1352, doi: 10.1145/3324884.3415298.
  6. M. Bresil, P. Prasad, M. S. Sayeed, and U. A. Bukar, “Deep learning-based vulnerability detection solutions in smart contracts: A comparative and meta-analysis of existing approaches,” IEEE Access, vol. 13, pp. 28 894–28 919, 2025, doi: 10.1109/ACCESS.2025.3532326.
  7. J. Scharfman, “Decentralized autonomous organization (DAO) fraud, hacks, and controversies,” in The Cryptocurrency and Digital Asset Fraud Casebook, Volume II: DeFi, NFTs, DAOs, Meme Coins, and Other Digital Asset Hacks. Springer, 2024, pp. 65–106, doi: 10.1007/978-3-031-60836-0 3.
  8. K. Polak, “Hack solidity: Reentrancy attack,” 2022. [Online]. Available: https://hackernoon.com/hack-solidity-reentrancy-attack

Details

Primary Language

English

Subjects

Data Security and Protection, Artificial Intelligence (Other), Computer Software

Journal Section

Research Article

Early Pub Date

October 27, 2026

Publication Date

October 30, 2026

Submission Date

October 31, 2025

Acceptance Date

June 28, 2026

Published in Issue

Year 2026 Volume: 9 Number: 5

APA
Bukar Usman, U., Umar, K., Isah Agaie, A., & Umar, M. (2026). LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection. Sakarya University Journal of Computer and Information Sciences, 9(5), 1387-1399. https://doi.org/10.35377/saucis...1810546
AMA
1.Bukar Usman U, Umar K, Isah Agaie A, Umar M. LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection. SAUCIS. 2026;9(5):1387-1399. doi:10.35377/saucis.1810546
Chicago
Bukar Usman, Usman, Kabir Umar, Aliyu Isah Agaie, and Mubarak Umar. 2026. “LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection”. Sakarya University Journal of Computer and Information Sciences 9 (5): 1387-99. https://doi.org/10.35377/saucis. 1810546.
EndNote
Bukar Usman U, Umar K, Isah Agaie A, Umar M (October 1, 2026) LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection. Sakarya University Journal of Computer and Information Sciences 9 5 1387–1399.
IEEE
[1]U. Bukar Usman, K. Umar, A. Isah Agaie, and M. Umar, “LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection”, SAUCIS, vol. 9, no. 5, pp. 1387–1399, Oct. 2026, doi: 10.35377/saucis...1810546.
ISNAD
Bukar Usman, Usman - Umar, Kabir - Isah Agaie, Aliyu - Umar, Mubarak. “LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection”. Sakarya University Journal of Computer and Information Sciences 9/5 (October 1, 2026): 1387-1399. https://doi.org/10.35377/saucis. 1810546.
JAMA
1.Bukar Usman U, Umar K, Isah Agaie A, Umar M. LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection. SAUCIS. 2026;9:1387–1399.
MLA
Bukar Usman, Usman, et al. “LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection”. Sakarya University Journal of Computer and Information Sciences, vol. 9, no. 5, Oct. 2026, pp. 1387-99, doi:10.35377/saucis. 1810546.
Vancouver
1.Usman Bukar Usman, Kabir Umar, Aliyu Isah Agaie, Mubarak Umar. LoCEBERT: Transformer-Based Line-of-Code Embeddings for Smart Contract Code Understanding and Vulnerability Detection. SAUCIS. 2026 Oct. 1;9(5):1387-99. doi:10.35377/saucis. 1810546

 

INDEXING & ABSTRACTING & ARCHIVING

 

31045 31044   Anadolu Türk Eğitim Dergisi  31047 

31043 28939 28938 34240
 

 

29070    The papers in this journal are licensed under a Creative Commons Attribution-NonCommercial 4.0 International License