IMPROVED DETECTION AND PATCHING OF BLOCKCHAIN SMART CONTRACT VULNERABILITIES USING ELECTRA-BASED TECHNIQUE
DOI:
https://doi.org/10.33003/fjs-2025-0910-4063Keywords:
Context-aware masking, Blockchain Smart contracts, Deep learning, TransformerAbstract
Blockchain smart contracts, increasingly integral to digital assets and decentralized applications, face growing threats from security vulnerabilities. Traditional detection techniques, such as static and dynamic analysis, often struggle with complex contracts and may overlook logic-based vulnerabilities. While machine learning approaches show promise, existing methods like ASSBERT suffer from inefficiency and limited coverage due to their reliance on direct masked token training applied to Solidity source code. To address these limitations, this study proposes an ELECTRA-based approach using context-aware masking to improve vulnerability detection and patch generation for blockchain smart contracts. Preliminary experiments demonstrate consistent convergence, with validation losses declining from 0.689 to 0.684 over four epochs. However, initial accuracy (50%) and F1 scores (0.333) indicate room for improvement, likely due to the model’s early-stage training or dataset constraints. By refining the masking strategy and leveraging ELECTRA’s bidirectional context understanding, our approach aims to enhance detection accuracy and generate more effective patches. This work offers a potential solution to the ongoing challenge of securing smart contracts, with future iterations targeting optimized performance metrics.
References
Aburass, S., Dorgham, O., & Rumman, M. A. (2024). An Ensemble Approach to Question Classification: Integrating Electra Transformer, GloVe, and LSTM. International Journal of Advanced Computer Science and Applications, 15(1). https://doi.org/10.14569/ijacsa.2024.0150148
Aladhadh, S., Alwabli, H., Moulahi, T., & Al Asqah, M. (2022). BChainGuard: A New Framework for Cyberthreats Detection in Blockchain Using Machine Learning. Applied Sciences, 12(23), 12026. https://doi.org/10.3390/app122312026
Arnab, A., Dehghani, M., Heigold, G., Sun, C., Lucic, M., & Schmid, C. (2021). ViViT: A Video Vision Transformer. 2021 IEEE/CVF International Conference on Computer Vision (ICCV), 6816–6826. https://doi.org/10.1109/iccv48922.2021.00676
Brauwers, G., & Frasincar, F. (2023). A General Survey on Attention Mechanisms in Deep Learning. IEEE Transactions on Knowledge and Data Engineering, 35(4), 3279–3298. https://doi.org/10.1109/TKDE.2021.3126456
Bu, J., Li, W., Li, Z., Zhang, Z., & Li, X. (2025). SmartBugBert: BERT-Enhanced Vulnerability Detection for Smart Contract Bytecode (No. arXiv:2504.05002). arXiv. https://doi.org/10.48550/arXiv.2504.05002
Cai, J., Li, B., Zhang, J., Sun, X., & Chen, B. (2023). Combine sliced joint graph with graph neural networks for smart contract vulnerability detection. Journal of Systems and Software, 195, 111550. https://doi.org/10.1016/j.jss.2022.111550
Chu, H., Zhang, P., Dong, H., Xiao, Y., Ji, S., & Li, W. (2023). A survey on smart contract vulnerabilities: Data sources, detection and repair. Information and Software Technology, 159, 107221. https://doi.org/10.1016/j.infsof.2023.107221
Clark, K., Luong, M.-T., & Le, Q. V. (2020). ELECTRA: PRE-TRAINING TEXT ENCODERS AS DISCRIMINATORS RATHER THAN GENERATORS.
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.
Fei, J., Chen, X., & Zhao, X. (2023). MSmart: Smart contract vulnerability analysis and improved strategies based on smartcheck. Applied Sciences, 13(3), 1733.
Ferreira, J. F., Cruz, P., Durieux, T., & Abreu, R. (2020). Smartbugs: A framework to analyze solidity smart contracts. 1349–1352.
Galal, O., Abdel-Gawad, A. H., & Farouk, M. (2024). Rethinking of BERT sentence embedding for text classification. Neural Computing and Applications, 36(32), 20245–20258. https://doi.org/10.1007/s00521-024-10212-3
Ivanov, N., Li, C., Yan, Q., Sun, Z., Cao, Z., & Luo, X. (2023). Security Defense For Smart Contracts: A Comprehensive Survey. ACM Computing Surveys, 55(14s), 1–37. https://doi.org/10.1145/3593293
Mi, F., Zhao, C., Wang, Z., Halim, S. M., Li, X., Wu, Z., Khan, L., & Thuraisingham, B. (2023). An Automated Vulnerability Detection Framework for Smart Contracts (No. arXiv:2301.08824). arXiv. https://doi.org/10.48550/arXiv.2301.08824
Pham Trong Linh, & Minh Thanh, T. (2023). Proposing of Imaging Graph Neural Network with Defined Security Pattern for Improving Smart Contract Vulnerability Detection. Research and Development on Information and Communication Technology, 70–79. https://doi.org/10.32913/mic-ict-research.v2023.n2.1198
Singh, S., & Mahmood, A. (2021). The NLP Cookbook: Modern Recipes for Transformer Based Deep Learning Architectures. IEEE Access, 9, 68675–68702. https://doi.org/10.1109/access.2021.3077350
Sun, X., Tu, L., Zhang, J., Cai, J., Li, B., & Wang, Y. (2023). ASSBert: Active and semi-supervised bert for smart contract vulnerability detection. Journal of Information Security and Applications, 73, 103423. https://doi.org/10.1016/j.jisa.2023.103423
Tang, X., Du, Y., Lai, A., Zhang, Z., & Shi, L. (2023). Deep learning-based solution for smart contract vulnerabilities detection. Scientific Reports, 13(1). https://doi.org/10.1038/s41598-023-47219-0
Usman, U. B., Umar, K., & Agaie, A. I. (2024). CodeELECTRA: An ELECTRA-based approach for improved vulnerability detection in blockchain smart contracts. Dutse Journal of Pure and Applied Sciences, 10(3b), 95–105. https://doi.org/10.4314/dujopas.v10i3b.11
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I. (2023). Attention Is All You Need (No. arXiv:1706.03762). arXiv. https://doi.org/10.48550/arXiv.1706.03762
Vidal, F. R., Ivaki, N., & Laranjeiro, N. (2024). OpenSCV: An Open Hierarchical Taxonomy for Smart Contract Vulnerabilities. Empirical Software Engineering, 29(4). https://doi.org/10.1007/s10664-024-10446-8
Yuan, X., Lin, G., Tai, Y., & Zhang, J. (2022). Deep Neural Embedding for Software Vulnerability Discovery: Comparison and Optimization. Security and Communication Networks, 2022, 1–12. https://doi.org/10.1155/2022/5203217
Downloads
Published
Issue
Section
Categories
License
Copyright (c) 2025 Baba Sale Ahmed, Usman Bukar Usman, Saleh Isa Kadai

This work is licensed under a Creative Commons Attribution 4.0 International License.