# Smart Contract Vulnerability Detection Based on Hybrid Attention Mechanism Model
## 5 Experiments and Results
### Experimental Results
Additionally, considering that only the reentrancy vulnerability can be detected by all three traditional tools, we present only its visual results in Figure 12f, where the four rows from front to back refer to Smartcheck, Oyente, Securify, and HAM, respectively. It is obvious that HAM outperforms existing methods. In order to further evaluate the detection effect of smart contract vulnerability detection technology based on deep learning, this paper investigates existing smart contract vulnerability detection tools, and selects three of them, such as Oyente, SmartCheck, and Securify, to compare with our proposed solution. The three tools have been widely used in the field of smart contract security. Table 6 shows the performance comparison results, \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Vulnerability**} & \multirow{2}{*}{**Performance**} & \multicolumn{6}{c}{**Models**} \\ \cline{3-10}  & & **RNN** & **LSTM** & **GRU** & **BiLSTM** & **BiGRU** & **BiGRU + Att** & **HAM** \\ \hline \multirow{4}{*}{Reentrancy} & Accuracy & 72.28\% & 86.02\% & 83.48\% & 85.57\% & 89.78\% & 90.94\% & 93.36\% \\  & Precision & 57.40\% & 87.18\% & 72.35\% & 74.73\% & 87.48\% & 89.40\% & 91.58\% \\  & Recall & 52.54\% & 62.56\% & 74.19\% & 82.59\% & 79.89\% & 81.23\% & 96.64\% \\  & F1 & 54.86\% & 72.84\% & 73.23\% & 78.46\% & 83.51\% & 85.12\% & 94.04\% \\ \hline \multirow{4}{*}{Arithmetic Vulnerability} & Accuracy & 67.19\% & 77.36\% & 78.26\% & 80.39\% & 79.16\% & 81.36\% & 80.85\% \\  & Precision & 76.57\% & 78.99\% & 80.61\% & 65.80\% & 65.38\% & 66.20\% & 79.65\% \\  & Recall & 54.56\% & 76.49\% & 72.47\% & 74.23\% & 46.23\% & 76.11\% & 71.89\% \\  & F1 & 63.72\% & 77.72\% & 76.32\% & 69.76\% & 54.16\% & 70.81\% & 75.57\% \\ \hline \multirow{4}{*}{Unchecked Return Value} & Accuracy & 72.18\% & 79.12\% & 80.28\% & 82.34\% & 81.39\% & 84.05\% & 82.56\% \\  & Precision & 56.64\% & 75.10\% & 72.18\% & 67.31\% & 65.68\% & 73.18\% & 81.24\% \\ \cline{1-1}  & Recall & 51.58\% & 56.21\% & 46.35\% & 76.20\% & 75.54\% & 73.02\% & 73.46\% \\ \cline{1-1}  & F1 & 53.99\% & 64.30\% & 56.45\% & 71.48\% & 70.27\% & 73.10\% & 77.15\% \\ \hline \multirow{4}{*}{Timestamp Dependency} & Accuracy & 65.76\% & 74.24\% & 79.02\% & 80.12\% & 80.29\% & 81.98\% & 85.62\% \\  & Precision & 61.46\% & 56.85\% & 82.11\% & 69.21\% & 83.37\% & 90.26\% & 87.03\% \\ \cline{1-1}  & Recall & 54.78\% & 51.33\% & 42.89\% & 53.26\% & 72.67\% & 82.29\% & 88.69\% \\ \cline{1-1}  & F1 & 57.97\% & 53.95\% & 56.81\% & 60.20\% & 77.65\% & 86.09\% & 87.85\% \\ \hline \multirow{4}{*}{Tx.origin} & Accuracy & 64.06\% & 73.57\% & 72.11\% & 73.11\% & 74.43\% & 86.11\% & 82.19\% \\ \cline{1-1}  & Precision & 73.57\% & 79.08\% & 72.26\% & 72.19\% & 79.67\% & 74.98\% & 81.45\% \\ \cline{1-1}  & Recall & 52.66\% & 70.41\% & 69.94\% & 74.57\% & 70.03\% & 74.13\% & 80.32\% \\ \cline{1-1}  & F1 & 61.38\% & 74.50\% & 71.8\% & 73.36\% & 74.54\% & 74.55\% & 80.88\% \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Performance Comparison of Deep Learning Models on Code Fragments. N/A denotes that the tool does not support the vulnerability. Thus, we have the following observations. From the table, we find that the proposed HAM in this paper outperforms the other three methods with an accuracy of 93.36%, a precision of 91.58%, recall of 96.64%, and an F1-score of 94.04%. However, there is not much difference in the recall rates of the five vulnerabilities, suggesting that HAM pays more attention to the detection rate of smart contracts with vulnerabilities. SmartCheck relies on some rigid and simple logical rules to detect vulnerabilities, which leads to low accuracy and F1-score. In addition, Securify has a highest recall of 92.48% on unchecked return value. In addition, the precision rate of the three traditional methods is low, and they have a high false positive rate in the detection process. The HAM method not only has a higher recall rate but also improves the precision rate, which is more conducive to vulnerability detection.