cred402/docs/integrations/coinbase-x402.md
caelum0x 7fdc321d79 feat: live-wire Casper writes, add marketing homepage, fix cold-start UX
Round 1 against STRATEGY-2026-10-23.md's backlog:

- Wire register_agent/stake/set_credit_score/deposit_liquidity to the real
  Casper Testnet contracts (lib/casper/live_bridge.ts), verified live against
  the real RPC node with a freshly generated (unfunded) keypair
  (npm run casper:keygen). Honesty flags built in for the Odra payable
  calling convention and the admin-gated set_credit_score call.
- Unblock NEAR's paid x402 route (npm run near:keygen generates a real
  implicit account id); QIE stays correctly flagged as blocked on unconfirmed
  external facts (asset contract, facilitator), not env plumbing.
- New public Home tab: live-stats hero, how-it-works, a real competitor
  comparison table, and a "90-second proof" that calls the real API live in
  the browser (verified end-to-end with gstack browse).
- Cold-start UX: visible retry state in X402Playground + the TS SDK, plus a
  keep-warm self-ping (lib/services/keepalive.ts) so the free Render dyno
  rarely idles out from under a real first-time caller.
- New GET /v1/credit-score/:agentId alias + docs/integrations/ samples for
  Skyfire/Nevermined/Coinbase x402.
- Self-hosting quickstart: root docker-compose.yml + scripts/bootstrap.sh,
  both run for real; fixed a real EACCES crash-loop bug in infra/Dockerfile
  (non-root user never owned the /data volume mount) found while verifying.

450/450 tests pass, typecheck clean, frontend build clean.
2026-10-23 19:57:40 +03:00

2.3 KiB

Coinbase x402 (the open standard) + cred402

cred402 is itself built on the x402 protocol (the Linux-Foundation-governed open standard Coinbase, AWS, Google, Stripe, Visa, Mastercard and Amex back) — it is not a competitor to x402, it is the credit layer that the base standard has no opinion about. If your agent already speaks x402 directly (Coinbase's reference facilitator, or any other), you do not need a new SDK to use cred402 — just one more call before you let an x402-authenticated agent run a balance instead of paying up front.

// Any agent/service that already handles the standard x402 402-challenge
// flow can drop this in right before it would otherwise require full
// up-front payment, to decide whether to offer "pay later" instead.
import { createHeaders } from "x402/client"; // illustrative — your existing x402 client

async function offerCreditInsteadOfUpfrontPayment(agentId: string, priceUsd: number): Promise<boolean> {
  const res = await fetch(`https://cred402-1.onrender.com/v1/credit-score/${encodeURIComponent(agentId)}`);
  if (res.status === 404) return false; // no cred402 history yet → require the normal x402 payment
  const { data } = await res.json();
  return data.eligible && priceUsd <= Number(data.credit.recommended_limit_cspr) * 0.04;
}

Two directions this composes in practice:

  1. x402 receipts → cred402 score. Every x402 payment an agent settles (on cred402 or anywhere using the same X-Payment header scheme) can feed its revenue history — see lib/x402 and agents/evidence_seller_agent.ts for the reference receipt shape. The more x402 volume an agent has, across however many rails, the better the score it can present anywhere.
  2. cred402 score → an x402 credit decision. A seller who'd otherwise demand payment before delivering can instead check the buyer's cred402 score and extend a short deferred-settlement window — turning a hard "pay or no service" 402 into a soft "we trust you for this one, settle within N days" based on real, auditable history instead of a guess.

The full working example (score → draw → repay, called live) is the "90- second proof" on the cred402 homepage (frontend/src/components/LiveProof.tsx) — the exact flow a lending agent built on raw x402 would compose.