Machine Learning Based Attack Detection and Prevention in Blockchain
Richard Essah
*
Computer Science Department, Takoradi Technical University, Ghana.
Augustine Danquah Yeboah
Computer Science Department, Takoradi Technical University, Ghana.
Kenneth Broni
Computer Science Department, Takoradi Technical University, Ghana.
*Author to whom correspondence should be addressed.
Abstract
Blockchain systems are increasingly deployed in finance, healthcare, supply chains, and IoT, but their open and decentralized nature exposes them to evolving security threats such as Sybil, eclipse, selfish mining, double-spending, and smart contract exploits. Traditional cryptographic safeguards and policy centered intrusion recognition approaches commonly fail to generalize against new strike variants, suffer from severe class imbalance, and struggle under real-time limitations. To examine these limitations, we present a hybrid deep learning framework that combines three complementary temporal encoders: a 1D Convolutional Neural Network (CNN) for short-term pattern extraction, a Bidirectional Long Short-Term Memory (Bi-LSTM) network for long-range dependencies, and a Transformer encoder for capturing global temporal context. Their outputs are fused with an attention mechanism and integrated into a unified classifier capable of both attack detection and automated prevention actions, such as quarantining suspicious transactions and sandboxing malicious contracts. Using the Cryptojacking Attack Timeseries dataset, the model achieves 97.21% accuracy, 99.16% Precision, 97.21%Recall, 97.98% F1-score, and an ROC-AUC of 0.9526, outperforming state-of-the-art baselines. The results demonstrate that multi-scale temporal fusion significantly enhances robustness and generalization under real-world blockchain conditions. This work contributes a scalable and adaptive detection–prevention pipeline, offering a practical pathway toward more secure decentralized ecosystems.
Keywords: Attack detection and prevention, blockchain, deep learning, machine learning