# Greenhead Labs

Public pay-per-call XRPL data and Grok AI. No accounts, JWT, or sessions. Pay XRP or RLUSD on XRPL mainnet (xrpl:0), then retry with X-Payment-Txid set to the validated Payment hash.

## When to use

Use this skill when you need XRPL token data, listings, DEX order books, portfolio balances, AMM/risk scores, or Grok AI, and you can pay a few drops of XRP or 0.01 RLUSD per call.

## Discover

1. Prefer `https://x402.greenhead.io/agents.json` then `https://x402.greenhead.io/.well-known/x402`.
2. Confirm `payments.x402.chains` includes `xrpl:0` and optionally `eip155:8453`.
3. Read `payTo` and per-endpoint prices from the catalog or from any HTTP 402 body. Do not hardcode the receive address.

## Pay

1. Send an XRPL Payment to catalog `payTo`: the listed XRP amount, or 0.01 RLUSD (issuer `rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De`).
2. After validation, retry the identical request with header `X-Payment-Txid` set to the 64-character Payment hash.
3. Do not send JWT, cookies, or API keys. The Payment hash is the credential. Each hash is single-use.

Base USDC path: pick the `eip155:8453` accept (asset `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`), sign an exact EIP-3009 payload, retry with `PAYMENT-SIGNATURE`. catalog priceXrp maps 1:1 to USDC face value (0.002 XRP SKU → 0.002 USDC = 2000 atomic). Not a live XRP/USD FX feed. Prove: `GET /v1/base/ping`.
4. Paid 200 responses include a `receipt` object and header `X-Payment-Receipt`. Unpaid calls return HTTP 402 with a stable `error` / `code` (see OpenAPI).
5. Optional `?campaign=` query, DestinationTag, or Payment memo is copied onto the receipt for attribution.
6. Verify a prior x402 Payment later with free `GET /v1/receipts/<txid>` (thin CFO JSON; no X-Payment-Txid).
7. Paid-call meters: free `GET /api/metrics`.
8. Paid ledger attestation of any Payment: `GET /v1/xrpl/settlement?txid=` (75,000 drops). Fail-closed before redeem. Not the free receipt lookup.

## Client

`npm i @greenhead/x402-fetch` wraps `fetch`. On 402, supply `pay({ payTo, priceDrops })` (you sign the XRPL Payment) or a prepaid `paymentTxid`. Retry sets `X-Payment-Txid`. Source: https://github.com/GreenheadLabs/x402/tree/main/packages/x402-fetch

```js
import { x402Fetch } from "@greenhead/x402-fetch";

const res = await x402Fetch("https://x402.greenhead.io/v1/xrpl/listings", {
  pay: async ({ payTo, priceDrops }) => txid,
});
```

## Call

- Free docs: https://x402.greenhead.io/docs.md
- OpenAPI: https://x402.greenhead.io/openapi.json
- Paid XRPL prefix: `https://x402.greenhead.io/v1/xrpl/*`
- Paid AI prefix: `https://x402.greenhead.io/v1/ai/*`
