With the rapid growth of the NFT market, the security of smart contracts has become crucial. However, existing AI-based detection models for NFT contract vulnerabilities remain limited due to their complexity, while traditional manual methods are time-consuming and costly. This study proposes an AI-driven approach to detect vulnerabilities in NFT smart contracts. We collected 16,527 public smart contract codes, classifying them into five vulnerability categories: Risky Mutable Proxy, ERC-721 Reentrancy, Unlimited Minting, Missing Requirements, and Public Burn. Python-processed data was structured into training/test sets. Using the CART algorithm with Gini coefficient evaluation, we built initial decision trees for feature extraction. A random forest model was implemented to improve robustness through random data/feature sampling and multitree integration. GridSearch hyperparameter tuning further optimized the model, with 3D visualizations demonstrating parameter impacts on vulnerability detection. Results show the random forest model excels in detecting all five vulnerabilities. For example, it identifies Risky Mutable Proxy by analyzing authorization mechanisms and state modifications, while ERC-721 Reentrancy detection relies on external call locations and lock mechanisms. The ensemble approach effectively reduces single-tree overfitting, with stable performance improvements after parameter tuning. This method provides an efficient technical solution for automated NFT contract detection and lays groundwork for scaling AI applications.
翻译:随着NFT市场的快速增长,智能合约的安全性变得至关重要。然而,现有的基于人工智能的NFT合约漏洞检测模型因其复杂性而仍然有限,而传统的手动方法则耗时且成本高昂。本研究提出了一种人工智能驱动的方法来检测NFT智能合约中的漏洞。我们收集了16,527个公开的智能合约代码,将其分为五类漏洞:可变代理风险、ERC-721重入、无限铸造、缺失要求以及公开销毁。经Python处理的数据被结构化为训练/测试集。利用CART算法和基尼系数评估,我们构建了初始决策树进行特征提取。通过随机森林模型,借助随机数据/特征采样和多树集成提高了鲁棒性。GridSearch超参数调优进一步优化了模型,三维可视化展示了参数对漏洞检测的影响。结果表明,随机森林模型在检测所有五类漏洞方面表现优异。例如,它通过分析授权机制和状态修改来识别可变代理风险,而ERC-721重入检测则依赖于外部调用位置和锁定机制。集成方法有效减少了单树过拟合,参数调优后性能稳定提升。该方法为自动化NFT合约检测提供了高效的技术解决方案,并为扩展人工智能应用奠定了基础。