AVERIFY-XYZ/averify-xyz

GitHub: AVERIFY-XYZ/averify-xyz

一款开源的跨链智能合约安全扫描器,用户粘贴合约地址即可在数秒内获得附带链上证据的自然语言安全判定。

Stars: 0 | Forks: 0

# AVERIFY [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/AVERIFY-XYZ/averify-xyz/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE) [![Node](https://img.shields.io/badge/Node.js-20%2B-green)](https://nodejs.org) [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-blue)](https://www.typescriptlang.org) AVERIFY 为每个人(不仅仅是开发者)提供跨 8 个网络的任何智能合约的自然语言安全判定。只需粘贴一个地址,选择一条链,几秒钟即可获得颜色编码的结果:**Safe**、**Caution** 或 **High Risk**。每一条发现都以通俗易懂的英语进行解释,并有你可以自行验证的链上证据作为支撑。 ## 功能 - **源码验证** — 确认可读代码与链上实际部署的代码一致 - **审计记录** — 检查该合约是否经过独立审计员的审查 - **风险模式检测** — self-destruct、无限铸币、暂停功能、代理升级等 - **所有权分析** — 单一钱包、multisig、timelock、DAO 或完全放弃所有权 - **可分享的报告** — 每次检查都会生成一个永久链接,你可以发送给任何人 - **SVG 徽章** — 直接在你项目的 README 中嵌入实时的信任徽章 - **Demo 模式** — 在未配置 API 密钥时,提供功能完备的 UI 和逼真的示例数据 ## 支持的网络 | 网络 | 浏览器 | |---|---| | Ethereum | Etherscan | | Polygon | PolygonScan | | Arbitrum | Arbiscan | | Optimism | Optimism Explorer | | Base | BaseScan | | BNB Chain | BscScan | | Avalanche | Snowtrace | | Stellar | Stellar Expert(无需密钥) | ## 快速开始 ### 1. 克隆并安装 ``` git clone https://github.com/AVERIFY-XYZ/averify-xyz.git cd AVERIFY # 安装 client 和 server 依赖 cd client && npm install cd ../server && npm install ``` ### 2. 配置服务器 ``` cd server cp .env.example .env ``` 打开 `server/.env` 并添加你免费的区块浏览器 API 密钥。如果没有密钥,应用将在 **demo 模式**下运行 —— 所有 UI 功能都将使用逼真的示例数据正常运行,但结果不是实时的链上数据。 ### 3. 启动两个服务 打开两个终端: ``` # Terminal 1 — backend(端口 3001) cd server && npm run dev # Terminal 2 — frontend(端口 5173) cd client && npm run dev ``` 然后打开 **[http://localhost:5173](http://localhost:5173)** ## 工作原理 ``` Browser (localhost:5173) │ │ GET /api/verify/ethereum/0xAbc... ▼ Vite dev proxy ──────────────────────────────────── vite.config.js │ │ forwards to http://localhost:3001 ▼ Express server (localhost:3001) │ ├── in-memory cache (node-cache, 5 min TTL) ├── SQLite cache (persisted reports) ├── live fetch (Etherscan-compatible APIs / Stellar Expert) └── ContractReport JSON ──────────────────────► browser ``` 在生产环境中,请在 `client/.env.local` 中设置 `VITE_API_URL=https://your-api.example.com`。 ## 项目结构 ``` AVERIFY/ ├── client/ # React + Vite frontend │ ├── src/ │ │ ├── components/ │ │ │ ├── layout/ # Header, Footer │ │ │ ├── search/ # Address input + chain selector │ │ │ ├── report/ # Verdict banner, checks grid, risks, badge, sources │ │ │ ├── home/ # How-it-works section, API key notice │ │ │ └── ui/ # Tooltip, Spinner │ │ ├── constants/ # Chain config (IDs, explorer URLs, icons) │ │ ├── hooks/ # useVerify — TanStack Query wrapper │ │ ├── services/ # api.ts — all HTTP calls to the backend │ │ └── types/ # TypeScript interfaces (mirrors server types) │ ├── vite.config.js # Dev proxy: /api → localhost:3001 │ └── package.json │ ├── server/ # Express + TypeScript backend │ ├── src/ │ │ ├── routes/ │ │ │ ├── verify.ts # GET /api/verify/:chainId/:address │ │ │ ├── reports.ts # GET /api/reports/:chainId/:address │ │ │ ├── audits.ts # GET + POST /api/audits │ │ │ └── badge.ts # GET /api/badge/:chainId/:address (SVG) │ │ ├── services/ │ │ │ └── verifier.ts # Fetches from explorer APIs + Stellar Expert │ │ ├── db/ │ │ │ ├── database.ts # SQLite connection via better-sqlite3 │ │ │ └── migrate.ts # Creates reports, audits, badge_submissions tables │ │ ├── middleware/ # Error handler, 404 │ │ ├── cache.ts # In-memory cache │ │ ├── config.ts # All env vars in one place │ │ ├── types.ts # Shared TypeScript interfaces │ │ └── index.ts # Express app entry point │ ├── .env.example │ └── package.json │ └── README.md ``` ## API 参考 | 方法 | Endpoint | 描述 | |---|---|---| | `GET` | `/api/verify/:chainId/:address` | 运行完整验证 —— 返回 `ContractReport` | | `GET` | `/api/reports/:chainId/:address` | 获取先前缓存的报告 | | `GET` | `/api/reports` | 列出最近检查过的 20 个合约 | | `GET` | `/api/badge/:chainId/:address` | 实时 SVG 信任徽章 | | `GET` | `/api/badge/status/:chainId/:address` | 徽章提交状态 | | `POST` | `/api/badge/submit` | 提交合约以进行徽章审核 | | `POST` | `/api/audits` | 注册审计记录 | | `GET` | `/health` | 服务器健康检查 | ## 环境变量 ### `server/.env` | 变量 | 默认值 | 描述 | |---|---|---| | `PORT` | `3001` | 服务器端口 | | `NODE_ENV` | `development` | 环境 | | `CLIENT_URL` | `http://localhost:5173` | 用于 CORS 的前端源 | | `DB_PATH` | `./averify.db` | SQLite 文件路径 | | `CACHE_TTL` | `300` | 缓存生命周期(以秒为单位) | | `RATE_LIMIT_WINDOW_MS` | `60000` | 速率限制窗口 | | `RATE_LIMIT_MAX` | `30` | 每个窗口内每个 IP 的最大请求数 | | `ETHERSCAN_KEY` | — | [etherscan.io](https://etherscan.io/myapikey) — Ethereum | | `POLYGONSCAN_KEY` | — | [polygonscan.com](https://polygonscan.com/myapikey) — Polygon | | `ARBISCAN_KEY` | — | [arbiscan.io](https://arbiscan.io/myapikey) — Arbitrum | | `OPTIMISM_KEY` | — | [optimistic.etherscan.io](https://optimistic.etherscan.io/myapikey) — Optimism | | `BASESCAN_KEY` | — | [basescan.org](https://basescan.org/myapikey) — Base | | `BSCSCAN_KEY` | — | [bscscan.com](https://bscscan.com/myapikey) — BNB Chain | | `SNOWTRACE_KEY` | — | [snowtrace.io](https://snowtrace.io/myapikey) — Avalanche | Stellar 使用公共的 Stellar Expert API —— 无需密钥。 ### `client/.env.local` | 变量 | 描述 | |---|---| | `VITE_API_URL` | 生产环境中的后端 URL。在开发环境中留空 —— Vite 代理会处理它。 | ## 技术栈 **前端** - [React 18](https://react.dev) + TypeScript - [Vite](https://vitejs.dev) — 构建工具和开发代理 - [Tailwind CSS](https://tailwindcss.com) — 样式 - [Framer Motion](https://www.framer.com/motion/) — 动画 - [TanStack Query](https://tanstack.com/query) — 服务器状态和缓存 - [Axios](https://axios-http.com) — HTTP 客户端 **后端** - [Node.js](https://nodejs.org) + [Express](https://expressjs.com) + TypeScript - [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) — 嵌入式数据库 - [Zod](https://zod.dev) — runtime 输入验证 - [Helmet](https://helmetjs.github.io) — 安全标头 - [express-rate-limit](https://github.com/express-rate-limit/express-rate-limit) — 速率限制 - [node-cache](https://github.com/node-cache/node-cache) — 内存缓存 - [tsx](https://github.com/privatenumber/tsx) — 开发环境中的 TypeScript 执行 ## 安全 - 所有区块浏览器 API 密钥均**仅在服务器端**使用 —— 绝不会暴露在浏览器的 bundle 中 - 速率限制:每个 IP 每分钟 30 次请求(可通过环境变量配置) - 每个响应都带有 Helmet 安全标头 - CORS 锁定为配置的 `CLIENT_URL` - 所有 POST 请求体在处理前均使用 Zod schema 进行验证 - SQLite 以 WAL 模式运行,以确保安全的并发读取 ## 许可证 [MIT](./LICENSE)
标签:MITM代理, TypeScript, Web3, 区块链安全, 安全插件, 智能合约, 自动化攻击