npm package: @quillai-network/x402-wach
Description: CLI SDK for WACH.AI token risk analysis via x402 payments
Latest version: 2.0.0

# x402-wach

A CLI and SDK for [WACH.AI](https://wach.ai) token risk analysis, powered by [x402](https://github.com/coinbase/x402) and secured with Coinbase [AWAL](https://www.npmjs.com/package/awal).

Payments are made in USDC on Base. Private keys are not stored in this project.

```bash
x402-wach verify-risk 0xA0b8...3E8 eth
```

## Security Model

- `x402-wach` no longer stores `wallet.json` or raw private keys.
- Signing and wallet custody are handled by AWAL and keys are secured with coinbase infrastructure
- The CLI can enforce per-request maximum payment (`--max-amount-atomic`).

## Quick Start

### Install

```bash
# Clone & install
git clone <repo-url> && cd x402-
npm install
npm run build

# Link CLI globally
npm link
```

### Set up AWAL wallet

```bash
# Check readiness
x402-wach wallet setup

# Start OTP login
x402-wach wallet login you@company.com

# Complete OTP verification
x402-wach wallet verify <flowId> <otp>

# Check wallet address and balance
x402-wach wallet address
x402-wach wallet balance
```

### Analyze a token

```bash
x402-wach verify-risk <TOKEN_ADDRESS> <CHAIN_NAME>
```

Example:

```bash
x402-wach verify-risk 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 eth
```

## Supported Chains

| Short Name | Chain               | Chain ID |
| ---------- | ------------------- | -------- |
| `eth`      | Ethereum            | 1        |
| `pol`      | Polygon             | 137      |
| `base`     | Base                | 8453     |
| `bsc`      | Binance Smart Chain | 56       |
| `sol`      | Solana              | solana   |

> The token being analyzed can be on any supported chain. Payment is always USDC on Base.

## CLI Commands

| Command                                                           | Description                                    |
| ----------------------------------------------------------------- | ---------------------------------------------- |
| `x402-wach verify-risk <tokenAddress> <chainName>`               | Analyze token risk (x402 payment via AWAL)     |
| `x402-wach verify-risk ... --max-amount-atomic 10000`            | Enforce max $0.01 x402 spend for that request  |
| `x402-wach wallet setup`                                          | Check AWAL install, auth, and funding readiness|
| `x402-wach wallet doctor [--min-usdc-atomic 10000]`              | Run AWAL diagnostics with remediation hints     |
| `x402-wach wallet login <email>`                                 | Start AWAL OTP login                           |
| `x402-wach wallet verify <flowId> <otp>`                         | Complete AWAL OTP verification                 |
| `x402-wach wallet status`                                         | Show raw AWAL status                           |
| `x402-wach wallet address`                                        | Show AWAL wallet address                       |
| `x402-wach wallet balance [--chain base|base-sepolia]`           | Show AWAL wallet balance                       |
| `x402-wach chains`                                                | List supported token analysis chains           |
| `x402-wach guide`                                                 | Show setup and usage guide                     |

## Programmatic Usage

```typescript
import { verifyTokenRisk, getAwalReadiness } from "@quillai-network/x402-wach";

const readiness = await getAwalReadiness(10_000);
if (!readiness.ready) {
  throw new Error(readiness.reasons.join("; "));
}

const report = await verifyTokenRisk(
  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "eth",
  { maxAmountAtomic: 10_000 }
);

console.log(report);
```

See `usage.md` for a complete SDK reference.

## License

MIT