Abstract Anomaly detection for smart contracts can effectively prevent hidden security risks such as financial fraud, illegal financing, and money laundering. Ethereum is currently the largest platform for smart contracts, and anomaly detection is imminent. However, the data related to smart contracts is huge and contains complex objects and relationships. It is impossible to extract high-order attributes and low efficiency using traditional methods. The key to reduce fraud is extracting features from complex smart contracts and effectively identifying abnormal contracts. Therefore, this paper constructs a Heterogeneous Graph Transformer Networks (S_HGTNs) suitable for smart contract anomaly detection to detect financial fraud on the Ethereum platform. To perform feature representation, this paper first extracts the features to construct a Heterogeneous Information Network (HIN) for smart contract, and uses the relationship matrix obtained from the meta-path learned in the transformer network as the input of the convolution network, and finally uses the node embedding for classification tasks. The classification results show that this model performs better than the traditional model and the standard deviation is small, which proves the effectiveness and stability of the model.