Original Research
Frontiers in Blockchain ·
Volume 9 - 2026 | https://doi.org/10.3389/fbloc.2026.1882027
Comparative evaluation of active learning, random sampling, and deep learning for smart contract vulnerability detection
- Gabriel Avelino Sampedro1,2*corresponding author
- Cheng Yanhui3,4*corresponding author
- Arlene Caballero1
- Made Adi Paramartha Putra5
- Nyoman Bogi Aditya Karna6
- Indriati2
- 1College of Technology, Lyceum of the Philippines University, Manila, Philippines
- 2Faculty of Computer Science, Universitas Brawijaya, Malang, Indonesia
- 3Taishan College of Science and Technology, Taian, Shandong, China
- 4Information Science and Engineering School of Shandong University, Qingdao, Shandong, China
- 5Faculty of Information Technology and Design, Primakara University, Denpasar, Bali, Indonesia
- 6Center of Excellence for Intelligent Sensing-IoT, Research Institute of Sustainable Society, Telkom University, Bandung, Indonesia
Abstract
Smart contracts are widely used to automate blockchain-based transactions and decentralised services, but vulnerabilities in their code can expose users and systems to financial loss, service disruption, and security compromise. Detecting vulnerable smart contracts remains challenging because reliable labelling often requires expert analysis, which makes fully labelled datasets costly to produce. This study investigates whether uncertainty-based active learning can reduce the labelling requirements for smart contract vulnerability detection using machine-learning classifiers. The BCCC-VulSCs-2023 dataset, containing 36,670 smart contract samples with 73 raw feature columns and a binary vulnerability label, was used for model development and evaluation. The dataset was preprocessed by removing constant and irrelevant columns, handling missing values, class balancing via SMOTE, an 80/20 train-test split, SelectKBest feature selection (top 14 features), and numerical feature normalisation. Random Forest, XGBoost, and CatBoost classifiers were evaluated under three conditions: uncertainty-based active learning, a random-sampling baseline with an identical labelling schedule, and a fully supervised baseline trained on the complete training set. LSTM, DNN, and GRU models were implemented as deep learning baselines. Under a fixed labelling budget (1,000 initial samples plus 4,000 samples queried per iteration over 10 iterations, totaling 41,000 of 43,062 available training labels), Random Forest and CatBoost with active learning achieved the strongest performance (73.7% and 73.9% test accuracy, respectively), outperforming XGBoost with active learning (69.1% accuracy) and all three deep learning baselines (66.7%–68.2% accuracy). However, under this budget, active learning showed no consistent advantage over the random-sampling baseline: test accuracy differed by less than 0.3 percentage points between active learning and random sampling across all three classifiers, and both approached the accuracy of the fully supervised baseline trained on the complete label set. These findings indicate that ensemble-based classifiers (Random Forest, CatBoost) are better suited to this structured smart contract feature representation than the evaluated deep learning baselines. However, at the labelling budget evaluated in this study, uncertainty-based active learning did not provide a measurable advantage over random sampling, suggesting that its benefit, if present, may only emerge at smaller labelling budgets than those tested here.
Keywords
1 Introduction
Computer programs known as smart contracts execute in response to predefined conditions, enabling trustless transactions by removing intermediaries through blockchain technology Wang et al. (2019). Due to their decentralised nature and self-executing capabilities, smart contracts are a significant advancement in contract management with the potential to transform sectors such as supply chain management, real estate, and finance Khan et al. (2021). They automate and enforce agreements in a more transparent, safe, and decentralised manner than traditional approaches Dwivedi et al. (2021). Still, even a small bug can have a significant impact: vulnerabilities in smart contracts can range from minor annoyances to significant financial losses and system failures Hasanova et al. (2019). A common vulnerability that can result in contract state manipulation or unauthorised access to funds is reentrancy Sharma (2023). In contrast, integer overflow/underflow vulnerabilities may lead to unintended actions, such as the creation of a large number of tokens or loss of income Noor and Murad (2023). Mitigating these risks requires thorough security audits, testing, adherence to best practices, ongoing monitoring, and prompt response to emerging threats Peng et al. (2021).
The main driving force behind efforts to fix smart contract vulnerabilities is the potential for disastrous effects on entire blockchain networks: a successfully exploited contract can undermine the reliability and security of the blockchain, leading to major disruptions and eroding user confidence Karisma (2024). Strengthening smart contract security is increasingly critical as cyberattacks become more frequent Krichen (2023), since exploited vulnerabilities increase the risk of financial loss, reputational damage, and systemic failure An (2020), and addressing them is necessary to preserve blockchain networks’ viability as a dependable foundation for decentralised applications Moin et al. (2019). However, reliable vulnerability labelling for training detection models typically requires expert analysis, making fully labelled datasets costly to produce.
This study investigates whether uncertainty-based active learning reduces labelling requirements for smart contract vulnerability detection. We evaluate three ensemble classifiers Random Forest, XGBoost, and CatBoost each under three conditions: active learning (an initial randomly sampled subset of 1,000 labelled instances, followed by 10 iterations querying 4,000 uncertainty-ranked samples each), an identically scheduled random-sampling control, and full supervision on the complete training set. These are compared against LSTM, DNN, and GRU deep learning baselines trained on the same preprocessed, feature-selected data. All models are evaluated using accuracy, precision, recall, and F1-score on a held-out test partition. This design isolates whether uncertainty-based sample selection provides a measurable advantage in labelling efficiency over naive random labelling, independent of the classifier used.
- Investigates whether uncertainty-based active learning reduces labelling requirements for smart contract vulnerability detection by comparing active learning against a random sampling baseline and a fully supervised baseline under an identical labelling schedule, using ensemble machine learning classifiers alongside deep learning baselines.
- Applies preprocessing, class balancing via SMOTE, an 80/20 train-test split, SelectKBest feature selection, and feature normalisation to the BCCC-VulSCs-2023 dataset to retain informative features and improve model performance.
- Evaluates Random Forest, XGBoost, and CatBoost under active learning, random sampling, and full supervision, alongside LSTM, DNN, and GRU deep learning baselines, using accuracy, precision, recall, and F1-score. The results show that Random Forest and CatBoost achieved the best performance among the evaluated models. In contrast, active learning showed no consistent advantage over random sampling within the evaluated labelling budget.
The rest of this paper is organised as follows. Section 2 reviews related work on smart contract vulnerability detection using active learning, machine learning, and deep learning. Section 3 describes the proposed detection approach, including dataset preprocessing, feature selection, active learning, and classifier implementation. Section 4 presents the experimental results and discussion. Section 5 concludes the study and outlines future work.
2 Related work
BwdBAL is a promising novel strategy Zhang et al. (2022) that researchers have introduced in the ongoing fight against vulnerabilities in smart contracts. This novel framework combines two advanced techniques: Bayesian Active Learning (BAL) and a backward noise removal method. While BAL carefully selects the most instructive data for the model to label, the backward noise-removal technique effectively eliminates errors in the labelled data. Upon conducting an exhaustive assessment of a vast dataset comprising thousands of smart contracts, the researchers found that BwdBAL outperforms both simpler active learning methods and traditional machine learning approaches. These findings suggest that BwdBAL has significant potential as a tool for efficiently identifying security flaws in smart contracts, thereby increasing the safety and reliability of blockchain networks. To improve detection precision, researchers developed ASSBert, a novel framework Sun et al. (2023), to address the lack of labelled data for smart contract vulnerability detection. This innovative method combines semi-supervised and active learning strategies to make the most of available data. By carefully selecting the most useful contracts for human labelling and leveraging a sizable pool of both labelled and unlabeled data, ASSBert enhances model performance. In addition, to understand the subtleties of smart contracts, ASSBert employs BERT, a powerful deep learning technique, during the analysis stage. While ASSBert performs better than baseline methods, the authors note that it is not yet publicly available and still needs to be evaluated on larger, real-world datasets.
The ESCORT framework is designed to identify vulnerabilities in Ethereum smart contracts quickly. Its distinctive methodology is based on a deep neural network (DNN) with a complex architecture Lutz et al. (2021) carefully crafted to improve detection precision. By separating feature extraction and vulnerability detection into distinct network branches, ESCORT can identify multiple threats with a single model. Because of its modular structure, ESCORT can quickly adapt to new vulnerabilities through transfer learning, effectively tackling evolving security threats. In testing, ESCORT found vulnerabilities with an average accuracy of 95%, and it analysed contracts in 0.02 s. These outstanding results highlight ESCORT’s potential to significantly enhance blockchain security and position it as a strong contributor to ongoing efforts to strengthen smart contracts against malicious exploits.
This study presents an innovative technique Abdelaziz and Hobor (2023) for utilising active learning to find vulnerabilities in smart contracts. This strategy focused efforts on the most important data. The suggested framework uses a two-step classification procedure that finds specific vulnerability types after identifying vulnerable contracts. Promising outcomes have been observed with this methodology, which balances accuracy with reduced labelling work. By making effective use of existing data, “Smart Learning to Find Dumb Contracts” makes meaningful progress in ongoing efforts to enhance the security of smart contracts.
To enhance smart contract security, this method applies a dual strategy HajiHosseinKhani et al. (2024). Initially, it generates transactions that aim to exploit potential contract vulnerabilities using a genetic algorithm inspired by natural evolution. The system looks at contract responses to these transactions and builds an extensive vulnerability profile. Furthermore, the research produced a benchmark dataset of smart contracts with known vulnerabilities. It will serve as a foundation for future training in vulnerability detection tools. The study’s findings demonstrate the genetic algorithm’s ability to detect vulnerabilities, and the benchmark dataset facilitates further investigations into how to make smart contracts more secure. This approach contributes meaningfully to ongoing efforts to protect smart contracts from vulnerabilities.
A new system called CI-ELT, designed for food supply chains monitored on the Ethereum blockchain, is presented in the paper Jaison and Janaki (2024). To address the issue of insufficient data for training vulnerability-detection models in smart contracts, CI-ELT combines semi-supervised learning, which leverages a large pool of unlabeled data, with active learning, which carefully selects informative data for labelling. This hybrid approach increases model accuracy while reducing the need for labelled data. In addition, CI-ELT uses blockchain technology to ensure secure and transparent data recording throughout the food supply chain. The evaluation’s conclusions highlight the need for further advancements and CI-ELT’s potential to improve food traceability and strengthen smart contract security within the Ethereum blockchain ecosystem.
A novel approach for detecting smart contract vulnerabilities is presented in the research study Li et al. (2023). This technique employs a combined strategy that uses multimodal feature fusion to analyse contracts from multiple angles, such as source code, operation code, and control flow. Following this extensive analysis, the system feeds data into deep learning models to identify intricate patterns indicative of security vulnerabilities. Experiments conducted on a dataset of vulnerable contracts yielded positive results, demonstrating the efficiency of this approach for detecting a range of security vulnerabilities in smart contracts.
Although existing studies have demonstrated the potential of active learning, semi-supervised learning, deep neural networks, and multimodal feature fusion for smart contract vulnerability detection, there remains a need for a direct empirical comparison between active learning-based ensemble classifiers and deep learning baselines using a consistent preprocessing and evaluation pipeline. There is also limited empirical evidence in this domain on whether uncertainty-based active learning provides a measurable advantage in labelling efficiency over simple random sampling under an equivalent labelling budget. This study addresses these gaps by evaluating Random Forest, XGBoost, and CatBoost under active learning, random sampling, and full supervision, and comparing them against LSTM, DNN, and GRU models on the same smart contract vulnerability dataset.
3 Proposed methodology
This paper investigates whether uncertainty-based active learning reduces labelling requirements for smart contract vulnerability detection. As shown in Figure 1, the approach begins with dataset preprocessing, followed by class balancing, an 80/20 train-test split, feature selection, feature normalisation, model training, and performance evaluation. For the ensemble classifiers (Random Forest, XGBoost, CatBoost), each model is first fit on an initial, randomly selected, labelled subset of 1,000 training samples. The remaining training data forms a separate query pool, distinct from both the initial labelled subset and the held-out test partition. At each of the 10 iterations, the model scores the pool based on predicted-probability uncertainty; the 4,000 most uncertain samples are added to the labelled training set along with their true labels; the model is retrained on the enlarged training set; and performance is evaluated on the untouched test partition. To assess whether uncertainty-based querying provides any advantage over naive labelling, the same procedure is repeated using random sampling instead of uncertainty scoring, with the same initial subset size, query size, and iteration schedule. A fully supervised baseline is also trained on the complete training set for each classifier. Deep learning models (LSTM, DNN, GRU) are implemented separately as baselines, using an internal validation split during training. The goal is to compare the label efficiency and classification performance of active learning against random sampling and full supervision, and to compare active learning-based ensemble classifiers against deep learning baselines on the same dataset and preprocessing pipeline.

As a fully-supervised baseline, each model is separately trained once on the complete training set X train , y train (all available labels) and evaluated once on the test partition X test , y test, using the same evaluation metrics.
Algorithm 1 Active Learning and Random-Sampling Implementation.
Algorithm 2 Deep Learning Implementation.
3.1 Dataset selection and preprocessing
The BCCC-VulSCs-2023 dataset was used in this study. It contains 36,670 smart contract samples with 73 raw feature columns, including bytecode-derived features, AST-derived features, keyword-frequency features, a hashed contract identifier, and a binary label indicating whether a contract is secure or vulnerable. An index column, the AST source identifier, and the hashed contract identifier were removed as they were not informative for classification, leaving 69 feature columns and the binary label. The dataset was checked for missing values, and none were found. Descriptive statistical analysis was performed, and the class distribution of the binary label was examined: 26,914 samples (73.4%) were labelled secure, and 9,756 samples (26.6%) were labelled vulnerable, indicating class imbalance. SMOTE oversampling was applied to the full feature set to balance the two classes, and then the data were split into training and test partitions. An 80/20 train-test split was then performed on the balanced data. SelectKBest with the ANOVA F-statistic was applied to the training partition to select the most informative features, and StandardScaler was subsequently fit on the training partition and applied to both the training and test partitions. These preprocessing steps were used to improve model reliability, reduce noise, and support more accurate vulnerability detection.
3.2 Feature selection
Feature selection was applied to reduce dimensionality and retain the most relevant input features for smart contract vulnerability classification. SelectKBest was implemented using the ANOVA f_classif scoring function. For each numerical feature, the ANOVA procedure compares the variation between the secure and vulnerable classes with the variation within each class. A larger F-statistic therefore indicates stronger univariate separation between the class labels. The candidate features were ranked by their ANOVA F-statistics computed on the training partition, and the top 14 features were retained for model training. The relative ANOVA F-statistic scores of the selected smart contract attributes are shown in Figure 2. This statistical filtering step was used to remove features with limited discriminative relevance, reduce input noise and computational cost, and limit unnecessary model complexity. However, the ANOVA procedure evaluates each feature independently. It does not directly account for nonlinear relationships, feature interactions, or redundancy among highly correlated predictors. Accordingly, the resulting scores are interpreted as measures of univariate relevance rather than as definitive measures of causal or model-specific feature importance. The 14 selected features and their ANOVA F-statistics are shown in Table 1. The keyword-frequency features view, emit, and external produced the largest F-statistics, followed by bytecode opcode-frequency features (weight_sums_MSTORE, weight_sums_DIV) and AST-derived structural features (AST_numberOf_nodes, AST_numberOf_exportedSymbols). These results indicate that both source-level keywords and structural/bytecode-level features contribute discriminative information for distinguishing secure from vulnerable contracts. To statistically validate the selected features, ANOVA F-statistics and corresponding p-values were calculated for all nonconstant numerical features on the training partition (post-SMOTE, post-split). The p-values were adjusted using the Benjamini–Hochberg false discovery rate procedure, and eta-squared ( η 2 ) was calculated to quantify the effect size. Feature-selection stability was evaluated using repeated stratified five-fold cross-validation with five repetitions (25 folds total). In every fold, the ANOVA ranking was recomputed using only that fold’s training partition, and the frequency with which each of the 14 selected features reappeared among the top 14 features was recorded. As shown in Table 1, all 14 selected features remained statistically significant after false-discovery-rate correction (p adj < 0.001 for all). The feature view produced the largest F-statistic ( F = 2591.33 ) and effect size ( η 2 = 0.0568 ), followed by emit and external. Thirteen of the 14 features were selected in all 25 cross-validation folds (100% stability); the feature q was selected in 14 of 25 folds (56%), indicating comparatively lower ranking stability than the other selected features. The effect sizes were small (ranging from 0.015 to 0.057), consistent with the interpretation that no single feature dominates the classification decision, and supporting the use of a multivariate ensemble model rather than reliance on individual features.

TABLE 1. Statistical validation and stability of the 14 selected features.
| Feature | F-statistic | Adjusted p-value | η 2 | Selection frequency |
|---|---|---|---|---|
| View | 2591.33 | < 1.0 × 1 0 − 300 | 0.0568 | 100% |
| Emit | 2058.20 | < 1.0 × 1 0 − 300 | 0.0456 | 100% |
| External | 1479.01 | < 1.0 × 1 0 − 300 | 0.0332 | 100% |
| weight_sums_MSTORE | 1146.70 | 7.39 × 1 0 − 247 | 0.0259 | 100% |
| Mapping | 1097.98 | 1.24 × 1 0 − 236 | 0.0249 | 100% |
| weight_sums_DIV | 1091.22 | 2.79 × 1 0 − 235 | 0.0247 | 100% |
| AST_numberOf_nodes | 1021.33 | 1.61 × 1 0 − 220 | 0.0232 | 100% |
| AST_numberOf_exportedSymbols | 1002.99 | 1.10 × 1 0 − 216 | 0.0228 | 100% |
| Require | 837.06 | 2.03 × 1 0 − 181 | 0.0191 | 100% |
| weight_sums_MUL | 832.22 | 1.97 × 1 0 − 180 | 0.0190 | 100% |
| weight_sums_EXP | 795.65 | 1.14 × 1 0 − 172 | 0.0181 | 100% |
| Not | 763.81 | 6.59 × 1 0 − 166 | 0.0174 | 100% |
| From | 710.74 | 1.35 × 1 0 − 154 | 0.0162 | 100% |
| q | 666.55 | 3.59 × 1 0 − 145 | 0.0152 | 56% |
3.3 Attacks description
Smart contracts are an essential component of blockchain transactions. Attacks on them can be extremely damaging to the system because even a tiny bug can compromise the entire network. Although the classification task in this study is binary, the following vulnerabilities are discussed to contextualise common security risks found in smart contracts.
3.3.1 Reentrancy attack
Reentrancy attacks occur when a malicious contract repeatedly calls a vulnerable contract before the original execution completes. This can lead to unauthorised fund withdrawals, balance manipulation, or unintended changes in contract logic. A common mitigation strategy is the Checks-Effects-Interactions pattern, in which validation checks and state updates are performed before any external contract interaction. Thorough testing, auditing, and secure coding practices are also necessary to reduce reentrancy risks.
3.3.2 Timestamp dependence
A vulnerability known as timestamp dependence in smart contracts occurs when a contract’s logic or execution depends on a transaction’s timestamp. Malicious actors manipulating transaction timestamps to their advantage, such as in sale or time-based unlocking mechanisms, can affect time-sensitive contract features. This flaw may result in unexpected actions or the financial exploitation of contract logic.
3.3.3 DoS attack
In smart contracts, a denial-of-service attack occurs when an attacker prevents normal contract execution or blocks legitimate users from interacting with the contract. This may occur due to excessive gas consumption, failed external calls, unexpected revert behaviour, or logic that prevents transactions from completing. Such attacks can disrupt decentralised applications and reduce the availability of blockchain-based services.
3.3.4 Phishing attack
In the context of smart contracts, phishing attacks involve using fake emails, websites, or social engineering tactics to trick users into interacting with malicious contracts or interfaces. These fake companies pose as legitimate businesses to trick users into disclosing their wallet addresses. Attackers may use this information once obtained to alter transactions, gain unauthorised access to accounts, or steal digital assets. Users’ confidence in smart contract systems could fall, leading to financial losses.
3.3.5 Transaction ordering dependence (TOD) attack
Transaction Ordering Dependency (TOD) attacks exploit variations in how miners handle transactions in blockchain networks such as Ethereum. By altering transactions within a block, an attacker can cause smart contracts to behave differently than intended, potentially resulting in financial losses or functional delays. This vulnerability puts the security of smart contracts and decentralised applications (DApps) at risk and highlights the importance of designing contracts with transaction order and independence in mind. Developers should include security features like timestamp verification and dependency tracking in their smart contract code to mitigate TOD attacks.
In this study, the query pool for active learning was built from the training partition remaining after the initial labelled subset was drawn and was kept separate from the test partition throughout. At each iteration, samples were sampled from this pool, added to the labelled training set with their true labels, and removed from the pool; the model was then retrained on the enlarged labelled set and evaluated on the untouched test partition. To assess whether uncertainty-based querying provided any benefit over naive labelling, the same procedure was repeated, using random sampling instead of uncertainty scoring, with the same initial subset size, query size, and iteration schedule. A fully supervised baseline, trained on the complete training partition, was evaluated identically for comparison.
3.4 Classification models
This section describes the models implemented to classify smart contracts as secure or vulnerable. The evaluated models include Random Forest, XGBoost, and CatBoost, each assessed under three conditions: uncertainty-based active learning, random sample selection, and full supervision, as well as LSTM, DNN, and GRU models used as deep learning baselines. The models were evaluated using accuracy, precision, recall, and F1-score to assess their effectiveness in detecting smart contract vulnerabilities.
3.4.1 Active learning models
Active learning is a machine learning approach in which the model iteratively selects the most informative samples for labelling or inclusion in the training process, rather than relying on a fixed labelled dataset. In this study, uncertainty sampling was used. At each iteration, the model’s predicted class probabilities on the query pool were used to estimate uncertainty, and the samples closest to the decision boundary were queried. This strategy is motivated by the fact that manually labelling smart contracts can be costly, time-consuming, and dependent on expert review. The uncertainty score for a pool sample x is given by Equation 1.where p ( x ) is the model’s predicted probability that x belongs to the vulnerable class. At each iteration, the q u e r y _ s i z e samples with the lowest u ( x ) values (greatest uncertainty) are selected for labelling. To evaluate whether this uncertainty-based selection provides a measurable advantage, it is compared directly with random sample selection and with a fully supervised model trained on all available labels, under identical initial subset sizes and labelling schedules for each classifier.
u x = p x − 0.5 (1)
Random Forest with Active Learning: Random Forest with active learning combines an ensemble of decision trees with an iterative sample selection strategy. Random Forest constructs multiple decision trees using bootstrapped training samples and random feature subsets. During prediction, the outputs of individual trees are aggregated to produce the final classification result. This ensemble structure improves robustness against noise and reduces the risk of overfitting compared with a single decision tree.
In this study, active learning, random sampling, and full supervision were each applied to Random Forest to assess whether uncertainty-based sample selection meaningfully improves vulnerability detection performance relative to these baselines. Equation 2 shows how Random Forest aggregates the predictions of its individual decision trees to produce the final classification.
y ̂ x = mode h 1 x , h 2 x , … , h T x (2)
XGBClassifier with Active Learning: XGBoost with active learning combines gradient-boosted decision trees with iterative sample selection. XGBoost builds an ensemble of weak decision trees, in which each new tree is trained to correct the errors of the previous trees by minimising a differentiable loss function. It is widely used for structured data due to its computational efficiency, regularisation mechanisms, and strong predictive performance. In this study, active learning, random sampling, and full supervision were each applied to XGBoost, following the same labelling schedule as Random Forest and CatBoost, to evaluate whether uncertainty-based sample selection improves smart contract vulnerability classification relative to these baselines. XGBoost’s prediction is an additive combination of weak learners, as shown in Equation 3.
F ̂ x = ∑ m = 1 M γ m h m x (3)
CatBoost Classifier: CatBoost is a gradient-boosting classifier designed to handle categorical and structured features effectively. It iteratively builds an ensemble of decision trees and applies ordered boosting to reduce prediction bias. CatBoost is useful for classification tasks because it can deliver stable performance with minimal preprocessing. In this study, CatBoost was likewise evaluated under active learning, random sampling, and full supervision, using the same initial subset size and labelling schedule as Random Forest and XGBoost, to determine its comparative effectiveness in detecting vulnerable smart contracts, as shown in equation Equation 4.
Log Loss = − 1 N ∑ i = 1 N ∑ j = 1 M y i j log p i j (4)
3.4.2 Deep learning models
Deep learning models were implemented as baseline classifiers to compare their performance with the active learning-based ensemble models. These models use multilayer neural network architectures to learn nonlinear relationships from input features. In this study, LSTM, DNN, and GRU models were evaluated to determine whether neural architectures could effectively detect vulnerable smart contracts from the selected and normalised feature set.
LSTM model Recurrent neural networks (RNNs) with the Long Short-Term Memory (LSTM) architecture are designed to capture long-range dependencies in sequential data and address the vanishing gradient problem that conventional RNNs suffer from. Because LSTMs have memory cells and gating mechanisms to control information flow, they can selectively update or forget information as needed and retain it for extended periods. In this study, the LSTM model consists of a single LSTM layer (64 units), followed by a dense layer (32 units, ReLU activation), a dropout layer (rate 0.5), and a softmax output layer. At each time step t, given input x t and previous hidden state h t − 1, the LSTM layer computes the gate and state updates shown in Equation 5.where f t, i t, and o t are the forget, input, and output gates, c t is the cell state, h t is the hidden state passed to the subsequent dense layers, and ⊙ denotes element-wise multiplication. The final hidden state is passed through the dense and output layers to produce class probabilities, y ̂ = softmax ( W 2 ReLU ( W 1 h t + b 1 ) + b 2 ), from which the predicted class is c ̂ = arg max j y ̂ j.
f t = σ W f h t − 1 , x t + b f i t = σ W i h t − 1 , x t + b i o t = σ W o h t − 1 , x t + b o c ̃ t = tanh W c h t − 1 , x t + b c c t = f t ⊙ c t − 1 + i t ⊙ c ̃ t h t = o t ⊙ tanh c t (5)
In this implementation, each input sample is reshaped to a sequence length of 1 timestep before being passed to the LSTM layer; the recurrence therefore reduces to a single gated transformation per sample from a zero-initialised hidden state, rather than genuine multi-step sequence modelling.
DNN model: Numerous hidden layers between the input and output layers characterise a deep neural network (DNN). These hidden layers enable DNNs to learn data structure representations, gradually abstracting features at different levels of complexity. DNNs use a technique called backpropagation to train by adjusting the weights of connections between neurons, thereby minimising the difference between expected and actual outputs. In this study, the DNN model consists of two dense hidden layers (64 and 32 units, ReLU activation, with a dropout rate of 0.5 after each), followed by a softmax output layer, as shown in Equation 6.where x is the input feature vector, h ( 1 ) and h ( 2 ) are the outputs of the first and second hidden layers (64 and 32 units, respectively), and the predicted class is c ̂ = arg max j y ̂ j.
h 1 = ReLU W 1 x + b 1 h 2 = ReLU W 2 h 1 + b 2 y ̂ = softmax W 3 h 2 + b 3 (6)
GRU model: The goal of developing Gated Recurrent Units (GRUs), a type of recurrent neural network (RNN), was to address the vanishing gradient problem and improve the modelling of temporal dependencies in sequential data. Update and reset gates are two gating mechanisms GRUs use to control the flow of information within the network. Unlike traditional RNNs, GRUs have a simpler architecture that improves computational efficiency while still capturing complex temporal patterns by combining the cell and hidden states. In this study, the GRU model consists of a single GRU layer (64 units), followed by a dense layer (32 units, ReLU activation), a dropout layer (rate 0.5), and a softmax output layer. At each time step t, the GRU layer computes the update and reset gate operations shown in Equation 7.where z t and r t are the update and reset gates, and h t is the hidden state passed to the subsequent dense layers in the same manner as the LSTM model, yielding y ̂ = softmax ( W 2 ReLU ( W 1 h t + b 1 ) + b 2 ) and c ̂ = arg max j y ̂ j.
z t = σ W z h t − 1 , x t + b z r t = σ W r h t − 1 , x t + b r h ̃ t = tanh W r t ⊙ h t − 1 , x t + b h t = 1 − z t ⊙ h t − 1 + z t ⊙ h ̃ t (7)
As with the LSTM model, each input sample is reshaped into a single timestep, so the GRU layer applies a single gated transformation per sample rather than modelling dependencies across multiple time steps.
4 Experimental analysis and results
This section presents the experimental evaluation of the proposed approach for detecting smart contract vulnerabilities. The evaluated models include Random Forest, XGBoost, and CatBoost, each assessed under active learning, random sampling, and full supervision, as well as LSTM, DNN, and GRU deep learning baselines. Model performance was assessed using accuracy, precision, recall, and F1-score. These metrics provide a balanced view of each model’s ability to classify secure and vulnerable smart contracts correctly. The comparison highlights the effectiveness of ensemble classifiers compared with deep learning baselines on the same dataset and under the same preprocessing conditions. It evaluates whether uncertainty-based active learning provides a measurable advantage over random sampling under an equivalent labelling budget.
While training accuracy measures how well a model performs on the training dataset, training loss quantifies the error between the predicted and actual values during training. This validation accuracy indicates the likelihood that the model will generalise to new data. The validation loss function computes the difference between the expected and actual values on the validation set to prevent overfitting and guide model training. The counts of true positives, true negatives, false positives, and false negatives are displayed in a confusion matrix, which helps visualise a classification model’s performance.
The confusion matrices in Figure 3 show that Random Forest and CatBoost produced fewer misclassifications than XGBoost and the evaluated deep learning baselines, under both active learning and random sampling. However, the active learning and random-sampling confusion matrices are nearly identical across classifiers, indicating that uncertainty-based sample selection did not meaningfully reduce misclassifications relative to random labelling within the labelling budget evaluated in this study. This result suggests that the strong performance of Random Forest and CatBoost is attributable primarily to their suitability for this structured feature representation, rather than to the active learning strategy itself. Further evaluation with smaller labelling budgets and additional datasets is needed to determine whether an active-learning advantage emerges under more constrained labelling conditions.

Compared with the evaluated deep learning baselines, Random Forest and CatBoost showed stronger performance across all labelling conditions, as seen in Figure 4. This is likely because tree-based ensemble models are better suited to the structured features used in this study. At the same time, the deep learning baselines may require richer code representations or larger training data to achieve comparable performance.

For the deep learning models, the training and validation accuracy curves (Figure 5) and loss curves (Figure 6) show stable convergence throughout training, with no evidence of severe overfitting. However, as shown in Table 2, absolute performance (66.7%–68.2% accuracy) remained below that of Random Forest and CatBoost, suggesting the flattened, non-sequential input representation used here may limit these architectures’ ability to exploit the structured feature set.


TABLE 2. Comparative performance of active learning, random-sampling, fully-supervised, and deep learning classifiers.
| Classifier | Condition | Precision | Recall | F1-score | Accuracy |
|---|---|---|---|---|---|
| Random forest | Active learning | 73.5% | 74.7% | 74.1% | 73.7% |
| Random sampling | 73.3% | 74.4% | 73.9% | 73.5% | |
| Fully supervised | 73.6% | 74.4% | 74.0% | 73.7% | |
| XGBoost | Active learning | 70.7% | 65.9% | 68.2% | 69.1% |
| Random sampling | 70.7% | 66.8% | 68.7% | 69.3% | |
| Fully supervised | 70.9% | 65.0% | 67.8% | 69.0% | |
| CatBoost | Active learning | 74.4% | 73.4% | 73.9% | 73.9% |
| Random sampling | 74.7% | 73.2% | 74.0% | 74.1% | |
| Fully supervised | 74.5% | 73.3% | 73.9% | 73.9% | |
| LSTM | 67.5% | 67.4% | 67.4% | 68.2% | |
| DNN | 66.9% | 66.9% | 66.8% | 66.7% | |
| GRU | 67.1% | 67.1% | 67.1% | 67.7% |
Table 3 presents the performance of the active-learning and random-sampling classifiers across 10 iterations. Random Forest and CatBoost achieved comparable, similarly trending performance under both active learning and random sampling, reaching approximately 73 74% accuracy by the final iteration. In contrast, XGBoost reached approximately 69% accuracy under both conditions. For all three classifiers, active learning and random sampling produced accuracy, precision, recall, and F1-score curves that stayed within roughly 0.3 percentage points of one another at every iteration, and both approached their respective fully-supervised accuracy (Random Forest: 73.68%; XGBoost: 69.00%; CatBoost: 73.94%; Table 2) by the tenth iteration. Figure 7 shows that all six configurations improved steadily over the first 4–5 iterations before plateauing, with no consistent separation between the active-learning and random-sampling curves for any classifier.
TABLE 3. Test-set performance across active learning and random-sampling iterations.
| Iterations | Model | Accuracy | Precision | Recall | F1-score |
|---|---|---|---|---|---|
| Iteration 1 | RF-AL | 68.837% | 69.685% | 67.356% | 68.501% |
| RF-random | 69.645% | 69.757% | 70.015% | 69.886% | |
| XGB-AL | 67.425% | 68.268% | 65.860% | 67.043% | |
| XGB-random | 68.113% | 69.361% | 65.583% | 67.420% | |
| CB-AL | 69.274% | 70.434% | 67.079% | 68.716% | |
| CB-random | 70.295% | 70.424% | 70.606% | 70.514% | |
| Iteration 2 | RF-AL | 70.973% | 71.683% | 69.922% | 70.792% |
| RF-random | 71.159% | 71.378% | 71.233% | 71.306% | |
| XGB-AL | 68.048% | 69.403% | 65.251% | 67.263% | |
| XGB-random | 68.428% | 70.198% | 64.716% | 67.346% | |
| CB-AL | 71.141% | 73.281% | 67.097% | 70.053% | |
| CB-random | 71.076% | 71.466% | 70.753% | 71.108% | |
| Iteration 3 | RF-AL | 72.590% | 72.187% | 74.040% | 73.102% |
| RF-random | 71.754% | 72.234% | 71.233% | 71.730% | |
| XGB-AL | 68.679% | 70.286% | 65.380% | 67.744% | |
| XGB-random | 68.558% | 70.494% | 64.494% | 67.361% | |
| CB-AL | 72.153% | 73.669% | 69.479% | 71.513% | |
| CB-random | 71.995% | 72.435% | 71.566% | 71.998% | |
| Iteration 4 | RF-AL | 73.481% | 73.354% | 74.261% | 73.805% |
| RF-random | 72.432% | 72.768% | 72.230% | 72.498% | |
| XGB-AL | 69.329% | 70.588% | 66.913% | 68.701% | |
| XGB-random | 69.199% | 70.883% | 65.805% | 68.250% | |
| CB-AL | 73.017% | 74.651% | 70.199% | 72.357% | |
| CB-random | 72.478% | 72.844% | 72.212% | 72.527% | |
| Iteration 5 | RF-AL | 73.574% | 74.462% | 72.249% | 73.339% |
| RF-random | 72.766% | 72.764% | 73.301% | 73.032% | |
| XGB-AL | 68.967% | 70.863% | 65.066% | 67.841% | |
| XGB-random | 68.688% | 70.487% | 64.956% | 67.608% | |
| CB-AL | 73.258% | 74.674% | 70.883% | 72.729% | |
| CB-random | 72.998% | 73.244% | 72.987% | 73.116% | |
| Iteration 6 | RF-AL | 73.806% | 74.262% | 73.357% | 73.806% |
| RF-random | 72.924% | 72.584% | 74.206% | 73.386% | |
| XGB-AL | 69.302% | 70.547% | 66.913% | 68.682% | |
| XGB-random | 69.088% | 69.954% | 67.578% | 68.745% | |
| CB-AL | 73.686% | 74.623% | 72.267% | 73.427% | |
| CB-random | 73.277% | 73.427% | 73.468% | 73.447% | |
| Iteration 7 | RF-AL | 73.723% | 74.074% | 73.486% | 73.779% |
| RF-random | 72.915% | 72.819% | 73.652% | 73.233% | |
| XGB-AL | 69.320% | 70.550% | 66.968% | 68.713% | |
| XGB-random | 69.088% | 70.755% | 65.713% | 68.141% | |
| CB-AL | 73.695% | 74.498% | 72.544% | 73.508% | |
| CB-random | 73.008% | 73.155% | 73.209% | 73.182% | |
| Iteration 8 | RF-AL | 73.760% | 73.836% | 74.095% | 73.966% |
| RF-random | 73.221% | 73.082% | 74.040% | 73.558% | |
| XGB-AL | 69.255% | 70.336% | 67.245% | 68.756% | |
| XGB-random | 69.441% | 70.697% | 67.042% | 68.821% | |
| CB-AL | 74.169% | 75.014% | 72.951% | 73.968% | |
| CB-random | 73.584% | 73.753% | 73.726% | 73.740% | |
| Iteration 9 | RF-AL | 73.509% | 73.497% | 74.040% | 73.767% |
| RF-random | 73.035% | 72.975% | 73.689% | 73.330% | |
| XGB-AL | 69.404% | 70.373% | 67.670% | 68.995% | |
| XGB-random | 69.246% | 70.625% | 66.544% | 68.524% | |
| CB-AL | 74.271% | 75.133% | 73.024% | 74.064% | |
| CB-random | 73.927% | 74.288% | 73.671% | 73.978% | |
| Iteration 10 | RF-AL | 73.741% | 73.506% | 74.742% | 74.119% |
| RF-random | 73.528% | 73.336% | 74.446% | 73.887% | |
| XGB-AL | 69.088% | 70.657% | 65.934% | 68.214% | |
| XGB-random | 69.348% | 70.672% | 66.784% | 68.673% | |
| CB-AL | 73.936% | 74.429% | 73.412% | 73.917% | |
| CB-random | 74.057% | 74.694% | 73.246% | 73.963% |

4.1 Discussion and comparison
The results show that ensemble-based classifiers are well-suited for smart contract vulnerability detection with this structured feature representation. As shown in Table 2, Random Forest and CatBoost achieved the strongest and comparable performance across all three evaluation conditions (active learning, random sampling, and full supervision), with test accuracy ranging from 73.5% to 73.7% for Random Forest and 73.9%–74.1% for CatBoost. Both clearly outperformed XGBoost (69.0% 69.3% accuracy across conditions) and all three deep learning baselines (LSTM: 68.2%, DNN: 66.7%, GRU: 67.7% accuracy). This indicates that ensemble-based models are more suitable than the tested deep learning baselines for the selected feature representation.
However, within each classifier, active learning did not provide a consistent advantage over random sampling: accuracy, precision, recall, and F1-score differed by less than one percentage point between the active learning and random-sampling conditions for Random Forest, XGBoost, and CatBoost alike, and both approached the performance of the fully supervised model trained on the complete label set. In two of the three classifiers (XGBoost and CatBoost), random sampling, in fact, achieved marginally higher final-iteration accuracy than uncertainty-based active learning. These results suggest that, under the labelling budget evaluated in this study (41,000 of 43,062 available training labels, or 95.2%), uncertainty-based sample selection offered no measurable label-efficiency benefit over naive random labelling. Because active learning is expected to provide the greatest benefit at small labelling budgets, where the choice of which samples to label most strongly influences model performance, this finding does not rule out a genuine active-learning advantage at substantially smaller budgets; it indicates only that no such advantage was observed at the budget tested here. These findings support the use of Random Forest or CatBoost as strong classifiers for this task, but, on their own, do not support active learning as the mechanism responsible for that performance.
5 Conclusion and future scope
This study evaluated whether uncertainty-based active learning reduces labelling requirements for smart contract vulnerability detection, using Random Forest, XGBoost, and CatBoost classifiers, compared against random-sampling and fully-supervised baselines, as well as LSTM, DNN, and GRU deep learning baselines. The BCCC-VulSCs-2023 dataset was preprocessed by removing irrelevant columns, handling missing values, performing class balancing with SMOTE, using an 80/20 train-test split, selecting features with SelectKBest, and normalising features. The results show that Random Forest and CatBoost achieved the strongest and comparable performance among the evaluated models (73.5% 74.1% test accuracy across conditions), outperforming XGBoost and all deep learning baselines. However, active learning did not provide a measurable advantage over random sampling for any of the three classifiers at the labelling budget evaluated (95.2% of available training labels), indicating that the observed performance is attributable primarily to the choice of ensemble classifier rather than to the active learning strategy itself. Future work should evaluate active learning across a range of smaller labelling budgets to determine whether uncertainty sampling provides a genuine label-efficiency advantage under more constrained labelling conditions, and should extend the evaluation using additional smart contract datasets, more advanced code representation techniques, transformer-based models, and external validation to improve generalizability and practical deployment. Future work should also examine multivariate and model-specific feature importance, nonlinear interactions among the selected features, and the stability of the feature ranking across external datasets.
Generative AI statement
The author(s) declared that generative AI was used in the creation of this manuscript. Language editing and formatting.
Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
Footnotes
Edited by: Anoop V. S, Amrita Vishwa Vidyapeetham, India
Reviewed by: Nimrita Koul, REVA University, India
Yu Luo, University of Central Missouri, United States
Statements
- Conflict of interest
The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
- Funding
The author(s) declared that financial support was not received for this work and/or its publication.
- Data availability
The original contributions presented in the study are included in the article/Supplementary Material, further inquiries can be directed to the corresponding authors.
- Author contributions
GS: Writing – review and editing, Writing – original draft. CY: Writing – review and editing, Writing – original draft. AC: Writing – review and editing, Writing – original draft. MP: Writing – review and editing, Writing – original draft. NA: Writing – review and editing, Writing – original draft. Indriati: Writing – original draft, Writing – review and editing.
References
- Abdelaziz T., Hobor A. (2023). “ Smart learning to find dumb contracts,” in 32nd USENIX Security Symposium (USENIX Security 23), 1775 – 1792.
- An J. (2020). Framing regulation around the potential liabilities of parties in the blockchain and smart contract industry. Fordham J. Corp. and Financial Law 25, 529. Availabel online at:.
- Dwivedi V., Norta A., Wulf A., Leiding B., Saxena S., Udokwu C. (2021). A formal specification smart-contract language for legally binding decentralized autonomous organizations. IEEE Access 9, 76069 – 76082. doi:10.1109/ACCESS.2021.3081926
- HajiHosseinKhani S., Lashkari A. H., Oskui A. M. (2024). Unveiling vulnerable smart contracts: toward profiling vulnerable smart contracts using genetic algorithm and generating benchmark dataset. Blockchain Res. Appl. 5, 100171. doi:10.1016/j.bcra.2023.100171
- Hasanova H., Baek U.-j., Shin M.-g., Cho K., Kim M.-S. (2019). A survey on blockchain cybersecurity vulnerabilities and possible countermeasures. Int. J. Netw. Manag. 29, e2060. doi:10.1002/nem.2060
- Jaison F., Janaki K. (2024). An efficient blockchain-based active learning semi-supervised smart contracts in ethereum blockchain traceable food supply chain. Int. J. Intelligent Syst. Appl. Eng. 12, 679 – 689. Availabel online at:.
- Karisma K. (2024). Security challenges in the application of blockchain technology in energy trading. Asian J. Law Policy 4, 51 – 75. doi:10.33093/ajlp.2024.3
- Khan S. N., Loukil F., Ghedira-Guegan C., Benkhelifa E., Bani-Hani A. (2021). Blockchain smart contracts: applications, challenges, and future trends. Peer-to-peer Netw. Appl. 14, 2901 – 2925. doi:10.1007/s12083-021-01127-0
- Krichen M. (2023). Strengthening the security of smart contracts through the power of artificial intelligence. Computers 12, 107. doi:10.3390/computers12050107
- Li J., Lu G., Gao Y., Gao F. (2023). A smart contract vulnerability detection method based on multimodal feature fusion and deep learning. Mathematics 11, 4823. doi:10.3390/math11234823
- Lutz O., Chen H., Fereidooni H., Sendner C., Dmitrienko A., Sadeghi A. R. (2021). Escort: Ethereum Smart Contracts Vulnerability Detection Using Deep Neural Network and Transfer Learning. arXiv Preprint arXiv:2103.12607
- Moin S., Karim A., Safdar Z., Safdar K., Ahmed E., Imran M. (2019). Securing iots in distributed blockchain: analysis, requirements and open issues. Future Gener. Comput. Syst. 100, 325 – 343. doi:10.1016/j.future.2019.05.023
- [Dataset] Noor M., Murad S. H. (2023). Identifying Threat Factors of Vulnerabilities in Ethereum Smart Contracts.
- Peng K., Li M., Huang H., Wang C., Wan S., Choo K.-K. R. (2021). Security challenges and opportunities for smart contracts in internet of things: a survey. IEEE Internet Things J. 8, 12004 – 12020. doi:10.1109/JIOT.2021.3074544
- Sharma M. (2023). Optimising Detection of Reentrancy Attacks in Solidity Smart Contracts. Ph.D. Thesis. Dublin: National College of Ireland.
- Sun X., Tu L., Zhang J., Cai J., Li B., Wang Y. (2023). Assbert: active and semi-supervised bert for smart contract vulnerability detection. J. Inf. Secur. Appl. 73, 103423. doi:10.1016/j.jisa.2023.103423
- Wang S., Ouyang L., Yuan Y., Ni X., Han X., Wang F.-Y. (2019). Blockchain-enabled smart contracts: architecture, applications, and future trends. IEEE Trans. Syst. Man, Cybern. Syst. 49, 2266 – 2277. doi:10.1109/TSMC.2019.2895123
- Zhang J., Tu L., Cai J., Sun X., Li B., Chen W. (2022). “ Vulnerability detection for smart contract via backward bayesian active learning,” in International Conference on Applied Cryptography and Network Security (Springer), 66 – 83.
Citation
Sampedro, G. A., et al. (2026). Comparative evaluation of active learning, random sampling, and deep learning for smart contract vulnerability detection. Frontiers in Blockchain, Volume 9. https://doi.org/
- Received
- Accepted
- Published
- Volume
- 9 - 2026
Copyright
Copyright © 2026 Sampedro, Yanhui, Caballero, Putra, Aditya Karna and Indriati.
License: https://creativecommons.org/licenses/by/4.0/
*Correspondence: Gabriel Avelino Sampedro; Cheng Yanhui
Article metrics
- Views
- 0
- Downloads
- 0
- Citations
- 0
- Shares
- 0
