Blockchain attack transaction analysis tool. Pull transaction artifacts (trace, contract source code, opcode) in one command, then automatically analyze attack transaction root causes via AI Agent.
Online version: txanalyzer.xyz
Tested on 18 real-world DeFi hack events from DeFiHackLabs, comparing AI-generated root cause analysis against human expert reports:
| Rank | Model | Notes |
|---|---|---|
| 1 | Claude Opus 4.6 | Best overall; deepest reasoning and trust boundary penetration |
| 2 | GPT-5.4 xhigh | Near-Opus quality; strong on complex multi-step exploits |
| 3 | GPT-5.4 high | Good balance of cost and accuracy |
| 4 | GPT-5.4 | Baseline; may miss subtle write-object causality |
source venv/bin/activate
pip install -r requirements.txt
python scripts/pull_artifacts.py --network bsc --tx 0xYOUR_TX_HASHAfter pulling artifacts, start a conversation in Cursor:
"Analyze this attack transaction 0xYOUR_TX_HASH on bsc"
The Agent will strictly follow the methodology to analyze and output transactions/<tx>/analysis/result.md.
Copy config_template.json to config.json and fill in your API keys:
{
"networks": {
"bsc": {
"name": "BSC Mainnet",
"rpc_url": "https://bnb-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_API_KEY",
"etherscan_api_key": "YOUR_BSCSCAN_API_KEY",
"etherscan_base_url": "https://api.etherscan.io/v2/api",
"chain_id": 56
}
},
"default_network": "bsc"
}TxAnalyzer/
├── docs/ # Analysis methodology & specifications (core)
│ ├── ATTACK_TX_ANALYSIS_METHODOLOGY.md # 6-phase workflow
│ ├── ATTACK_TX_ANALYSIS_SPEC.md # Mandatory gates & stop conditions
│ ├── ATTACK_TX_ANALYSIS_MODULES.md # Modular checklists
│ └── ATTACK_TX_ANALYSIS_DEEP_DIVE.md # Deep root cause investigation
├── txanalyzer/ # Core analysis library
│ ├── tx_analyzer.py # TransactionTraceAnalyzer
│ ├── transaction_processor.py
│ └── heimdall_api.py
├── scripts/ # CLI entry scripts
│ ├── pull_artifacts.py # Pull transaction artifacts
│ ├── backfill_opcodes.py
│ ├── cleanup.py # Clean up transaction artifacts
│ └── decompile.py # Contract decompilation
├── .cursor/ # Cursor AI Agent configuration
│ ├── skills/attack-tx-analysis/ # Analysis workflow orchestration Skill
│ └── rules/ # Methodology enforcement Rule
├── assets/ # Images and static assets
│ └── benchmark.png # AI vs Human RCA benchmark
├── config.json # Network configuration (not committed)
├── config_template.json # Configuration template
└── requirements.txt
python scripts/pull_artifacts.py --network bsc --tx 0x...Common parameters:
--tx: Required, transaction hash--network: Optional, defaults tobsc--timeout: Optional, defaults to120--skip-opcode: Skipdebug_traceTransaction--reuse-log: Reuse existing log file
python scripts/cleanup.py --tx 0x... --dry-run
python scripts/cleanup.py --tx 0x...python scripts/decompile.pyThe analysis is driven by Cursor Agent, strictly following 4 methodology documents:
- Pull Artifacts:
pull_artifacts.pyfetches trace / contract source code / opcode / selector mappings - Phase 1-6 Analysis: Follows the 6-phase workflow in
ATTACK_TX_ANALYSIS_METHODOLOGY.md - SPEC Self-Check: After each phase, validates against gates and constraints in
ATTACK_TX_ANALYSIS_SPEC.md - Module Triggers: Executes checklists when trigger conditions in
ATTACK_TX_ANALYSIS_MODULES.mdare met - Deep Dive: After Phase 6, penetrates trust boundaries per
ATTACK_TX_ANALYSIS_DEEP_DIVE.md
This project ships with a Claude Code skill (CLAUDE.md) that turns Claude into an end-to-end attack transaction analyst. When loaded, Claude will:
- Pull artifacts — run
pull_artifacts.pyto fetch trace, contract source code, opcodes, and selector mappings - Read all 4 methodology docs —
METHODOLOGY,SPEC,MODULES,DEEP_DIVE(cannot be skipped) - Execute 6-phase analysis — Triage → Graphs → Hypotheses → Evidence → Closure → Deliverable, with SPEC self-check after each phase
- Deep root cause drilling — penetrate every trust boundary and audit each validation function line-by-line
- Output
result.md— one-sentence root cause, evidence chain, reproduction steps, fix recommendations, confidence rating
# 1. Ensure config.json is set up with your API keys
cp config_template.json config.json
# Edit config.json to fill in Alchemy RPC URL and Etherscan API Key
# 2. Start Claude Code from the project root
claude
# 3. Ask Claude to analyze a transaction
> Analyze attack transaction 0xYOUR_TX_HASH on bscClaude will automatically activate the virtual environment, pull artifacts, read the methodology, and produce an audit-grade report at transactions/<tx>/analysis/result.md.
| Constraint | Description |
|---|---|
| Write-object-first Gate | Must verify "whose ledger was credited" before classifying as Read-type |
| Victim-first Gate | Must draw victim subgraph when third-party extraction is detected |
| Falsification order | Write before Read — skipping is prohibited |
| Trust boundary penetration | Every validation function on the attack path must be audited line-by-line |
| Module triggers | When trigger conditions are met (e.g., batch liquidation, ERC4626 manipulation), the corresponding module checklist must be executed |
| Confidence gate | high requires ≥1 write-object evidence; low if no gate passed |
| Network | Config Key |
|---|---|
| BSC Mainnet | bsc (default) |
| Ethereum Mainnet | eth |
| Sepolia Testnet | sepolia |
| Polygon Amoy | polygon_amoy |
After execution, artifacts are generated in: transactions/<tx_hash>/ (the directory includes a README.md explaining each subdirectory).
Analysis result: transactions/<tx_hash>/analysis/result.md
