Skip to content

Official implementation of **SmartTrans: Advanced Similarity Analysis for Detecting Vulnerabilities in Ethereum Smart Contracts**.

Notifications You must be signed in to change notification settings

vul337/SmartTrans

Repository files navigation

SmartTrans

SmartTrans Workflow

Official implementation of SmartTrans: Advanced Similarity Analysis for Detecting Vulnerabilities in Ethereum Smart Contracts. The Model and Dataset are released at NextCloud

Prerequisites

  • Linux OS (Tested on Ubuntu 24.04.2 LTS)
  • Python 3.8+
  • PyTorch 1.10+ with CUDA 10.2+
  • NVIDIA Drivers (Tested with 550.135)
  • Gigahorse-toolchain (for bytecode CFG analysis)

Quick Start

Environment Setup

  1. Create and activate conda environment:
conda create -n smarttrans python=3.8 -y
conda activate smarttrans
  1. Install dependencies:
pip install tqdm pandas transformers faiss-gpu accelerate datasets wandb
  1. Clone repository:
git clone https://github.com/vul337/SmartTrans.git && cd SmartTrans
  1. Download and extract models and datasets: Please download and extract the models from NextCloud
tar -xzvf *.tar.gz
mkdir index/
mv searching_index.index index/
mv searching_ebds_list.pkl index/

Usage

Analyzing Custom Smart Contracts

  1. Preprocess bytecode using Gigahorse-toolchain (set TEMP_PATH in 1.Analyze_gigahorse.py to point to Gigahorse's .temp directory)
python3 1.Analyze_gigahorse.py
  1. Run preprocessing and inference:
python3 2.Preprocess.py
python3 3.SaveEmbedding.py
  1. Retrieve similar functions:
python3 4.Retrieve.py

Training

Pre-Training

train.sh

Finetuning

finetune.sh

Reproducibility

The exact conda environment configuration is provided in smarttrans_env.yaml.

Citation

If this work is helpful for your research, please consider citing the following BibTeX entry.

@article{chen2025smarttrans,
  title={SmartTrans: Advanced Similarity Analysis for Detecting Vulnerabilities in Ethereum Smart Contracts},
  author={Chen, Longfei and Wang, Hao and Zhou, Yuchen and Wong, Taiyu and Wang, Jialai and Zhang, Chao},
  journal={IEEE Transactions on Dependable and Secure Computing},
  year={2025},
  publisher={IEEE}
}

About

Official implementation of **SmartTrans: Advanced Similarity Analysis for Detecting Vulnerabilities in Ethereum Smart Contracts**.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published