IDEAS home Printed from https://ideas.repec.org/p/hal/journl/hal-04979285.html
   My bibliography  Save this paper

Smart contract anomaly detection: The Contrastive Learning Paradigm

Author

Listed:
  • Oumaima Fadi

    (UIR - International University of Rabat, Rabat, Morocco)

  • Adil Bahaj

    (UIR - International University of Rabat, Rabat, Morocco)

  • Karim Zkik

    (ESC [Rennes] - ESC Rennes School of Business)

  • Abdellatif El Ghazi

    (UIR - International University of Rabat, Rabat, Morocco)

  • Mounir Ghogho

    (University of Leeds)

  • Mohammed Boulmalf

    (UIR - International University of Rabat, Rabat, Morocco)

Abstract

Smart contracts are digital agreements automating the execution of transactions in a decentralized manner. Although they offer many advantages, smart contracts are prone to multiple security vulnerabilities that might cause severe financial losses. Traditional anomaly detection methods, including Machine Learning and Deep Learning, struggle to capture the complexity of smart contract features. Recent advancements have utilized graph neural networks (GNNs) by transforming smart contracts into graphs. However, these approaches face robustness challenges due to small data sizes and model overparameterization. To address these issues, this paper proposes ACAD (Adaptive Contrastive Learning for Smart Contract Attack Detection), a novel framework employing a two-phase training process for smart contract classification. After converting smart contract codes to representative graphs, the task-agnostic features are learned using graph contrastive learning with adaptive augmentations. Next, these features are utilized for smart contract vulnerability classification in a downstream task. Unlike previous works, which rely on a single-phase GNN-based approach, ACAD leverages contrastive learning to improve robustness and generalization. This approach effectively overcomes data scarcity while capturing richer and more distinctive representations. Extensive experiments demonstrate that ACAD outperforms baseline models, achieving 95.7% accuracy and 92.44% precision in reentrancy attack detection, which represents an improvement of 5.78% in accuracy and 6.19% in precision compared to the best-performing baseline model.

Suggested Citation

  • Oumaima Fadi & Adil Bahaj & Karim Zkik & Abdellatif El Ghazi & Mounir Ghogho & Mohammed Boulmalf, 2025. "Smart contract anomaly detection: The Contrastive Learning Paradigm," Post-Print hal-04979285, HAL.
  • Handle: RePEc:hal:journl:hal-04979285
    DOI: 10.1016/j.comnet.2025.111121
    as

    Download full text from publisher

    To our knowledge, this item is not available for download. To find whether it is available, there are three options:
    1. Check below whether another version of this item is available online.
    2. Check on the provider's web page whether it is in fact available.
    3. Perform a search for a similarly titled item that would be available.

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:hal:journl:hal-04979285. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: CCSD (email available below). General contact details of provider: https://hal.archives-ouvertes.fr/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.