base-token-safety-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +37 -0
  2. package/index.d.ts +18 -0
  3. package/index.js +51 -0
  4. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @antigravity/token-safety-client
2
+
3
+ Node.js/browser API client for the [Antigravity Token Safety Scanner](https://antigravity-connect-ia.vercel.app/token-safety). Scan any Base chain token address for rug pulls, honeypots, and dangerous functions.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @antigravity/token-safety-client
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ const { scanToken, getLatestScans } = require("@antigravity/token-safety-client");
15
+
16
+ const result = await scanToken("0x4200000000000000000000000000000000000006");
17
+ console.log(result.symbol, result.safetyScore, result.riskLevel);
18
+ // WETH 10 "safe"
19
+
20
+ const latest = await getLatestScans(5);
21
+ console.log(latest.map((s) => `${s.symbol}: ${s.safetyScore}/10`));
22
+ ```
23
+
24
+ ## API
25
+
26
+ ### `scanToken(address)`
27
+ Scans a Base chain token address. Returns `{ address, symbol, name, safetyScore, riskLevel, risks, dangerousFunctions, note }`.
28
+
29
+ ### `getLatestScans(limit?)`
30
+ Returns the latest scanned tokens from the live watcher (up to 50).
31
+
32
+ ### `formatScore(score)`
33
+ Converts 0-10 numeric score to `"safe" | "warning" | "danger"`.
34
+
35
+ ## Web
36
+
37
+ Full interactive scanner: [antigravity-connect-ia.vercel.app/token-safety](https://antigravity-connect-ia.vercel.app/token-safety)
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ export interface ScanResult {
2
+ address: string;
3
+ symbol: string;
4
+ name: string | null;
5
+ safetyScore: number;
6
+ riskLevel: "safe" | "warning" | "danger";
7
+ risks: string[];
8
+ dangerousFunctions: Array<{ sig: string; desc: string }>;
9
+ note: string | null;
10
+ }
11
+
12
+ export class TokenSafetyError extends Error {
13
+ status: number;
14
+ }
15
+
16
+ export function scanToken(address: string): Promise<ScanResult>;
17
+ export function getLatestScans(limit?: number): Promise<ScanResult[]>;
18
+ export function formatScore(score: number): "safe" | "warning" | "danger";
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ const BASE_URL = "https://antigravity-connect-ia.vercel.app";
2
+
3
+ class TokenSafetyError extends Error {
4
+ constructor(message, status) {
5
+ super(message);
6
+ this.name = "TokenSafetyError";
7
+ this.status = status;
8
+ }
9
+ }
10
+
11
+ async function request(path, body) {
12
+ const res = await fetch(`${BASE_URL}${path}`, {
13
+ method: "POST",
14
+ headers: { "Content-Type": "application/json" },
15
+ body: JSON.stringify(body),
16
+ });
17
+ const data = await res.json();
18
+ if (!res.ok || data.error) {
19
+ throw new TokenSafetyError(data.error || `HTTP ${res.status}`, res.status);
20
+ }
21
+ return data;
22
+ }
23
+
24
+ function formatScore(score) {
25
+ return score >= 8 ? "safe" : score >= 5 ? "warning" : "danger";
26
+ }
27
+
28
+ async function scanToken(address) {
29
+ if (!address || !/^0x[a-fA-F0-9]{40}$/.test(address)) {
30
+ throw new TokenSafetyError(`Invalid address: ${address}`);
31
+ }
32
+ const data = await request("/api/token-safety", { address });
33
+ return {
34
+ address: data.address || address,
35
+ symbol: data.symbol || "UNKNOWN",
36
+ name: data.name || null,
37
+ safetyScore: data.safetyScore ?? 0,
38
+ riskLevel: formatScore(data.safetyScore ?? 0),
39
+ risks: data.risks || [],
40
+ dangerousFunctions: data.dangerousFunctions || [],
41
+ note: data.note || null,
42
+ };
43
+ }
44
+
45
+ async function getLatestScans(limit = 10) {
46
+ const res = await fetch(`${BASE_URL}/api/latest-scans?limit=${limit}`);
47
+ if (!res.ok) throw new TokenSafetyError(`HTTP ${res.status}`, res.status);
48
+ return res.json();
49
+ }
50
+
51
+ module.exports = { scanToken, getLatestScans, formatScore, TokenSafetyError };
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "base-token-safety-client",
3
+ "version": "1.0.0",
4
+ "description": "Node.js/browser API client for the Antigravity Token Safety Scanner. Scan any Base chain token address for rug pulls, honeypots, and dangerous functions.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": ["index.js", "index.d.ts", "README.md"],
8
+ "keywords": [
9
+ "base-chain",
10
+ "token-scanner",
11
+ "rug-pull-detector",
12
+ "honeypot-checker",
13
+ "crypto-security",
14
+ "web3",
15
+ "defi-security",
16
+ "smart-contract-audit",
17
+ "api-client"
18
+ ],
19
+ "author": "Antigravity Labs",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/josemiguel3125-sketch/live-agent-os-infra.git"
24
+ },
25
+ "engines": {
26
+ "node": ">=18"
27
+ }
28
+ }