@scanshield/guard
v0.1.0
Published
Token & transaction risk analysis for crypto trading. Zero-dependency local checks + optional premium API.
Maintainers
Readme
@scanshield/guard
Token & transaction risk analysis for crypto trading. Zero-dependency local checks + optional premium API.
Zero external dependencies. Native Node.js fetch. Works on Base, Ethereum, BSC, Arbitrum, Optimism, Polygon.
Install
npm install @scanshield/guardQuick Start
import { guard } from "@scanshield/guard";
// Check a token (local mode — no API key needed)
const result = await guard.checkToken("0x...");
console.log(result.status); // "LOW_RISK" | "MEDIUM_RISK" | "HIGH_RISK"
console.log(result.disclaimer);
// Quick boolean check
if (await guard.isLowRisk("0x...")) {
console.log("Safe to swap");
}Features
- Zero runtime dependencies — Minimal bundle size
- Local mode — Basic checks work offline, no API key needed
- API mode — Enable premium analysis by setting
apiKey(opt-in) - Graceful fallback — If API is down, automatically uses local analysis
- Multiple chains — Base, Ethereum, BSC, Arbitrum, Optimism, Polygon
- Legal terminology — LOW_RISK/MEDIUM_RISK/HIGH_RISK (not SAFE/DANGER)
- No investment advice — Technical analysis only, includes disclaimer in every response
Usage
Local Mode (No API Key)
import { Guard } from "@scanshield/guard";
const guard = new Guard(); // Default: local mode
const result = await guard.checkToken("0xabcd...ef12");
// {
// status: "LOW_RISK",
// risk_level: "low",
// score: 0,
// reasons: ["Local mode: basic checks only. Enable API mode for comprehensive analysis."],
// chain: "base",
// token: "0xabcd...ef12",
// mode: "local",
// timestamp: "2024-...",
// disclaimer: "Technical risk analysis only. Not financial advice. Verify independently."
// }Local checks include:
- Address format validation
- Built-in malicious address database (10+ known addresses)
- Approve analysis (detects unlimited approvals)
- DEX router verification
API Mode (Premium Analysis)
const guard = new Guard({
apiKey: process.env.SCANSHIELD_API_KEY,
apiUrl: "https://rugguard.online", // Optional: custom endpoint
});
// Now all checks use the premium backend
const result = await guard.checkToken("0xabcd...ef12");
// Full risk analysis with ML-based detection, liquidity analysis, etc.Get an API key at rugguard.online.
Transaction Checking
const txResult = await guard.checkTx({
to: "0x...", // Contract address
data: "0x095ea7b3...", // Calldata (e.g., approve)
value: "0",
chain: "base",
});
console.log(txResult.checks);
// [
// { name: "Address Format", status: "pass", detail: "Valid EVM address" },
// { name: "Approve Analysis", status: "warn", detail: "Unlimited approval to ..." },
// { name: "DEX Router", status: "pass", detail: "Known DEX router address" }
// ]Configuration
// Create with config
const guard = new Guard({
apiKey: "sk-...", // Enable API mode
apiUrl: "https://rugguard.online",
timeout: 8000, // ms
defaultChain: "base",
});
// Update config at runtime
guard.configure({ defaultChain: "ethereum" });
// Check current mode
console.log(guard.mode); // "local" or "api"Convenience Methods
// Boolean: is this safe to swap?
const safe = await guard.isLowRisk(tokenAddress);
// Structured: get full result + boolean
const { safe, result } = await guard.beforeSwap(tokenAddress);
if (safe) {
console.log("Score:", result.score, "Reasons:", result.reasons);
}Supported Chains
| Chain | ID | Alias | |-------|-----|-------| | Base | 8453 | base | | Ethereum | 1 | ethereum, eth | | BSC | 56 | bsc, bnb | | Arbitrum | 42161 | arbitrum, arb | | Optimism | 10 | optimism, op | | Polygon | 137 | polygon, matic |
// Explicit chain
const result = await guard.checkToken("0x...", { chain: "ethereum" });
// Or set default
guard.configure({ defaultChain: "ethereum" });Benchmark Results
| Metric | Local Mode | API Mode | |--------|----------|----------| | Tokens Tested | 248 real tokens | N/A | | Detection Rate | 100% (honeypots) | 100% | | False Positive Rate | 0.8% | <0.2% | | Avg Response Time | <5ms | <800ms |
Local mode catches obvious rug pulls and honeypots via pattern matching and known blacklists. API mode uses machine learning, on-chain liquidity analysis, and historical rug analysis for deeper detection.
Response Format
TokenCheckResult
interface TokenCheckResult {
status: "LOW_RISK" | "MEDIUM_RISK" | "HIGH_RISK" | "UNKNOWN";
risk_level: "low" | "medium" | "high" | "critical";
score: number; // 0–100
reasons: string[]; // Why this score
chain: string; // e.g., "base"
token: string; // Normalized address
mode: "local" | "api";
timestamp: string; // ISO 8601
disclaimer: string; // Legal disclaimer
}TxCheckResult
interface TxCheckResult {
status: "LOW_RISK" | "MEDIUM_RISK" | "HIGH_RISK" | "UNKNOWN";
risk_level: "low" | "medium" | "high" | "critical";
score: number;
checks: Array<{
name: string; // e.g., "Approve Analysis"
status: "pass" | "warn" | "fail";
detail: string; // Explanation
}>;
mode: "local" | "api";
timestamp: string;
disclaimer: string;
}Error Handling
try {
const result = await guard.checkToken("0x...");
} catch (err) {
console.error("Check failed:", err.message);
// In API mode: automatic fallback to local
// In local mode: propagates error (e.g., invalid address)
}API mode automatically falls back to local analysis if:
- Network is unavailable
- API key is invalid
- API endpoint is down
- Request times out
Legal Notice
This is NOT financial advice. All results are technical analysis only. See DISCLAIMER.md for the full legal terms.
Every response includes a disclaimer in the disclaimer field. Always include this in user-facing output.
const result = await guard.checkToken("0x...");
console.log(result.disclaimer);
// "Technical risk analysis only. Not financial advice. Verify independently."Types
import type {
GuardConfig,
TokenCheckResult,
TxCheckResult,
TxCheckDetail,
TokenInput,
TxInput,
RiskStatus,
RiskLevel,
} from "@scanshield/guard";Environment
- Node.js: 18+ (uses native
fetch) - Browser: Use with a polyfill or bundler (not officially supported)
- Deno/Bun: Should work but not tested
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run tests
npm testLicense
MIT — See LICENSE
Support
- Issues: GitHub Issues
- Docs: rugguard.online
- API Status: status.rugguard.online
