Views
No views yet
| Metric | Score |
|---|---|
| F1 (weighted, test set) | 98.6% |
| Eval Loss | 0.0428 |
| Test Samples | 1,032 contracts |
| Classes | 13 vulnerability categories |
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="emekaphilians/trustchainai-codebert"
6)
7
8contract = """
9pragma solidity ^0.8.0;
10contract Vulnerable {
11 mapping(address => uint) public balances;
12 function withdraw() external {
13 uint amt = balances[msg.sender];
14 (bool ok,) = msg.sender.call{value: amt}("");
15 balances[msg.sender] = 0;
16 }
17}
18"""
19
20result = classifier(contract[:512])
21print(result)
22# [{'label': 'reentrancy', 'score': 0.997}]| ID | Label | Description |
|---|---|---|
| 0 | safe | No vulnerability detected |
| 1 | reentrancy | Reentrancy attack (DAO-style) |
| 2 | integer_overflow | Arithmetic overflow / underflow |
| 3 | access_control | Unprotected ownership or selfdestruct |
| 4 | tx_origin_phishing | tx.origin used for authentication |
| 5 | dos_gas | Unbounded loop / gas exhaustion |
| 6 | unchecked_call | External call return value ignored |
| 7 | front_running_mev | Mempool-visible state / TOD |
| 8 | timestamp_dependence | block.timestamp manipulation |
| 9 | proxy_storage_collision | Delegatecall storage slot collision |
| 10 | flash_loan_oracle | Oracle price manipulation via flash loan |
| 11 | flash_loan_single_block | Single-block liquidity attack |
| 12 | misnamed_constructor | Pre-Solidity-0.5 constructor naming bug |
| 13 | other | Multi-class or miscellaneous vulnerability |
| Source | Contracts |
|---|---|
| SmartBugs Curated | 143 |
| SolidiFI Benchmark | 1,700 |
| DeFiHackLabs | 729 |
| Not-So-Smart Contracts | 25 |
| Synthetic augmentation | 3,600 |
| Total (after dedup) | 6,879 |
| Parameter | Value |
|---|---|
| Base model | microsoft/codebert-base |
| Epochs | 5 (best checkpoint at epoch 2) |
| Batch size | 16 |
| Learning rate | 2e-5 |
| Optimizer | AdamW (weight decay 0.01, warmup 100 steps) |
| Max token length | 512 |
| Mixed precision | fp16 |
| Hardware | Google Colab T4 GPU |
tx_origin_phishing class has limited real training samples (28); treat predictions for this class with extra cautiontx_origin_phishing class had only 28 real-world training samples; model confidence for this class may be lower in practice.1@misc{trustchainai2025,
2 author = {Emeka Philian},
3 title = {TrustChainAI: AI-Powered Smart Contract Auditor},
4 year = {2025},
5 url = {https://github.com/emekaphilian/TrustChainAI}
6}