This VS Code extension integrates GitHub Copilot, Slither static analysis, and Hardhat. It enforces a feedback loop where code suggestions are immediately checked for security vulnerabilities and deployment gas costs before leaving the editor.
The extension orchestrates data flow between the AI, the static analyzer, and the local blockchain node:
┌─────────────────────────────────────────┐
│ VS Code Extension (TypeScript) │
│ ┌────────────────────────────────────┐ │
│ │ Prompt Enhancement + Safety Checks │ │
│ └────────────────────────────────────┘ │
└─────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
Copilot Slither Hardhat
│ │ │
└──────────────┴──────────────┘
│
▼
Artifact Store
(JSON, CSV, Gas)
| Component | Functionality |
|---|---|
| Template Injection | Pre-loads OpenZeppelin security patterns into the prompt context. |
| Slither Runner | Runs static analysis via Docker (30s timeout) on file save. |
| Safety Mode | Detects mainnet chain IDs and blocks accidental deployment. |
| Gas Profiler | Logs gas usage per function via Hardhat interactions. |
| Artifact Logger | Saves all run data to JSON/CSV for auditing. |
- VS Code 1.93+
- Node.js 16+
- Docker (Required for Slither)
- Git
- Clone the repo:
git clone https://github.com/JoeDkhar/SlitherAI-Toolkit.git
cd web3-copilot-extension- Install Extension:
cd extension
npm install
npm run compile- Install Hardhat Project:
cd ../sample-hardhat
npm install- Environment:
cp .env.example .env
# Add your SEPOLIA_RPC_URL and PRIVATE_KEY- Run:
Press
F5or navigate to Run and Debug → Run Extension.
To run the full evaluation pipeline used in the performance metrics:
cd sample-hardhat
bash scripts/run_evaluation.shThis will:
- Compile contracts with the settings in
hardhat.config.js. - Deploy to the local Hardhat node.
- Run synthetic user interactions (
scripts/interact.js). - Generate gas and security reports in
repro-artifacts/.
If you are replicating the results, note the following configurations:
- Gas Optimization: The reported 43% gas reduction relies on specific compiler settings. Ensure your
hardhat.config.jsincludes:
optimizer: { enabled: true, runs: 200 }- Slither Version: Results may vary slightly depending on the Slither version. This project was tested using the
ghcr.io/crytic/slitherDocker image. - Synthetic Data: The interaction scripts (
interact.js) use automated transactions to ensure consistent gas measurements. These are not recorded from human typing sessions. - Scope: The provided templates support EVM-compatible networks (Ethereum, Sepolia, Localhost).
web3-copilot-extension/
├── extension/ # VS Code Extension Source (TypeScript)
│ ├── src/extension.ts # Main logic (Safety checks, orchestration)
│ └── package.json
├── sample-hardhat/ # Testbed Project
│ ├── contracts/ # ERC20 Templates
│ ├── scripts/ # Automation & Evaluation Scripts
│ ├── reports/ # Output JSONs
│ └── hardhat.config.js # Compiler Config
├── repro-artifacts/ # Raw Experiment Logs
└── slither-output.json # Static Analysis Findings