|
1 | 1 | # GraphDeeSmartContract    |
2 | 2 |
|
3 | | -This repo is a python implementation of smart contract vulnerability detection of our DR-GCN network. |
| 3 | +This repo is a python implementation of smart contract vulnerability detection using graph neural networks (DR-GCN). |
4 | 4 |
|
5 | | -### Running project |
6 | | -* To run program, use this command: python SmConVulDetector.py. |
| 5 | + |
| 6 | +## Requirements |
| 7 | +### Required Packages |
| 8 | +* **python**3 or above |
| 9 | +* **PyTorch**1.0.0 |
| 10 | +* **numpy**1.18.2 |
| 11 | +* **sklearn** for model evaluation |
| 12 | + |
| 13 | +Run the following script to install the required packages. |
| 14 | +``` |
| 15 | +pip install --upgrade pip |
| 16 | +pip install torch==1.0.0 |
| 17 | +pip install numpy==1.18.2 |
| 18 | +pip install scikit-learn |
| 19 | +``` |
| 20 | + |
| 21 | + |
| 22 | +## Citation |
| 23 | +Please use this citation if you want to cite our [paper](https://www.ijcai.org/Proceedings/2020/0454.pdf) or codebase in your paper: |
| 24 | +``` |
| 25 | +@inproceedings{ijcai2020-454, |
| 26 | + title = {Smart Contract Vulnerability Detection using Graph Neural Network}, |
| 27 | + author = {Zhuang, Yuan and Liu, Zhenguang and Qian, Peng and Liu, Qi and Wang, Xiang and He, Qinming}, |
| 28 | + booktitle = {Proceedings of the Twenty-Ninth International Joint Conference on |
| 29 | + Artificial Intelligence, {IJCAI-20}}, |
| 30 | + publisher = {International Joint Conferences on Artificial Intelligence Organization}, |
| 31 | + pages = {3283--3290}, |
| 32 | + year = {2020}, |
| 33 | +} |
| 34 | +
|
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | +## Running project |
| 39 | +* To run program, use this command: python SMVulDetector.py. |
7 | 40 | * In addition, you can use specific hyper-parameters to train the model. All the hyper-parameters can be found in `parser.py`. |
8 | 41 |
|
9 | 42 | Examples: |
10 | 43 | ```shell |
11 | | -python SmConVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671 |
12 | | -python SmConVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671 --model gcn_modify --n_hidden 192 --lr 0.001 -f 64,64,64 --dropout 0.1 --vector_dim 100 --epochs 50 --lr_decay_steps 10,20 |
| 44 | +python SMVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671 |
| 45 | +python SMVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671 --model gcn_modify --n_hidden 192 --lr 0.001 -f 64,64,64 --dropout 0.1 --vector_dim 100 --epochs 50 --lr_decay_steps 10,20 |
13 | 46 | ``` |
14 | 47 |
|
15 | 48 | Using script: |
16 | 49 | Repeating 10 times for different seeds with `train.sh`. |
17 | 50 | ```shell |
18 | 51 | for i in $(seq 1 10); |
19 | 52 | do seed=$(( ( RANDOM % 10000 ) + 1 )); |
20 | | -python SmConVulDetector.py --model gcn_modify --seed $seed | tee logs/smartcheck_"$i".log; |
| 53 | +python SMVulDetector.py --model gcn_modify --seed $seed | tee logs/smartcheck_"$i".log; |
21 | 54 | done |
22 | 55 | ``` |
23 | 56 | Then, you can find the training results in the `logs/`. |
24 | 57 |
|
25 | 58 |
|
26 | 59 | ### Dataset |
27 | | -Original smart contract source code: |
28 | | - |
29 | | -Ethereum smart contracts: [Etherscan_contract](https://drive.google.com/open?id=1h9aFFSsL7mK4NmVJd4So7IJlFj9u0HRv) |
| 60 | +ESC: [Ethereum Smart Contracts](https://drive.google.com/open?id=1h9aFFSsL7mK4NmVJd4So7IJlFj9u0HRv) |
30 | 61 |
|
31 | | -Vntchain smart contacts: [Vntchain_contract](https://drive.google.com/open?id=1FTb__ERCOGNGM9dTeHLwAxBLw7X5Td4v) |
| 62 | +VSC: [Vntchain Smart Contacts](https://drive.google.com/open?id=1FTb__ERCOGNGM9dTeHLwAxBLw7X5Td4v) |
32 | 63 |
|
33 | 64 | The train data after normalization: |
34 | 65 |
|
|
0 commit comments