cred402/docs/integrations/nevermined.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

1.9 KiB

Nevermined + cred402: underwrite before you settle

Nevermined meters and settles agent-to-agent payments (Free / $250/mo / $500/mo + a 1-2% take rate). It moves money between agents; it does not decide whether an agent that can't pay in full right now should be allowed to run up a balance. cred402 is the underwriting layer you put in front of that decision.

Pattern: before letting a Nevermined-metered call proceed on credit (a subscription draw-down, a deferred settlement, a running tab), call cred402's credit score for the paying agent and gate on it.

# curl — works against the hosted reference deployment or your own `npm run dev`.
curl -s https://cred402-1.onrender.com/v1/credit-score/weather-risk-agent-01 | jq
{
  "success": true,
  "data": {
    "schema_version": "cred402.credit-score.v1",
    "agent_id": "weather-risk-agent-01",
    "score": 81,
    "risk_band": "low",
    "probability_of_default": 0.012,
    "eligible": true,
    "reason_codes": ["LOW_DISPUTE_RATE", "STAKE_BACKING"],
    "credit": { "recommended_limit_cspr": "49.19", "interest_rate_bps": 884 },
    "x402_revenue": { "last_30_days_cspr": "127.1", "receipt_count": 410 }
  }
}

Wire it into a Nevermined metering middleware:

import { NeverminedAgentPayments } from "@nevermined-io/payments"; // illustrative import

async function beforeSettle(agentId: string, amountUsd: number): Promise<"allow" | "deny"> {
  const res = await fetch(`https://cred402-1.onrender.com/v1/credit-score/${encodeURIComponent(agentId)}`);
  if (!res.ok) return "deny"; // unknown or errored → fail closed, never guess
  const { data } = await res.json();
  return data.eligible && amountUsd <= Number(data.credit.recommended_limit_cspr) * 0.04 ? "allow" : "deny";
}

This turns Nevermined's metering/settlement layer and cred402's scoring layer into complements rather than competitors: Nevermined still owns "move the money," cred402 owns "should you let the balance run."