A typical contract would necessitate the use of an intermediary, make a payment to them, then wait for the record to return. Through a smart contract, though, it is as easy as putting the bitcoin into the vending machine, and the products would be published instantly. Smart contracts are Blockchain-based autonomous software. On Ethereum, a vast number of smart contracts have been deployed. Meanwhile, transaction security vulnerabilities have resulted in significant financial damages and have harmed the contract layer’s ecological integrity on Blockchain. As a result, detecting contract bugs reliably and efficiently is a new yet critical problem. Currently, available identification approaches, such as Oyente and Securify, depend primarily on symbolic execution or analysis. Since symbolic execution necessitates the discovery of all executable routes or the study of dependence diagrams in a contract, these approaches are time-consuming. In this paper, we suggest SmartPol, a machine learning-based method for detecting vulnerabilities in smart contracts. First, we use a data pre-processor to clean up the data before extracting features and classifying them. Second, we present a PSOGSA-based method for data optimisation and function extraction and a TSVM-based approach for semi-supervised learning classification models to identify smart contract vulnerabilities automatically. On EtherScan, SmartPol was used to test 49512 real-world smart contracts. The experimental findings show SmartPol’s reliability and efficacy. When we use PSOGSA for function extraction and TSVM classification sets, SmartPol’s predictive precision and accuracy are over 96%, and the average prediction time is 4 seconds on each smart contract.