Replace the design-note docs (p1–p7) with the implemented "make it real" phase docs (p8–p10) and wire production-grade, env-gated real integrations: - p8 Casper Testnet: byte-exact deploys + WASM install via casper-js-sdk; live node reads (node.testnet.casper.network); CRED402_CHAIN=sim|testnet transport. - p9 x402 + data + MCP: real EIP-712 typed-data digests (@casper-ecosystem/ casper-eip-712); casper-x402 facilitator client (x402 V2); live Open-Meteo GHI; official @modelcontextprotocol/sdk server; casper-sidecar SSE event feed. - p10 RealFi + cross-chain: real Stripe test-mode webhooks (HMAC-verified) and Plaid sandbox → privacy-preserving on-chain envelopes; Base Sepolia EVM deploy (Foundry); reachable via /api/realfi/* and /api/x402/facilitator routes. - Sign-in with Casper Wallet: real extension provider + challenge/ed25519/session flow (/v1/auth/wallet/*), console connect + sign-in button. - Branding: Cred402 logo mark, favicon, OG image; Vercel config for the console. All env-gated with sim/free-API fallbacks; full suite green, all toolchains (TS/Rust/Go/Solidity) build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4.3 KiB
p10 — Real RealFi + real cross-chain
Make it real, phase 3. The human-economy and other-chain rails stop being mocks: real Stripe test-mode webhooks (verified HMAC) and real Plaid sandbox bank checks flow through the RealFi Bridge into privacy-preserving on-chain envelopes, and the EVM satellite compiles and deploys for real to Base Sepolia via Foundry. Casper stays the canonical root — fiat and EVM are satellites that anchor back.
1. Real Stripe (test mode)
lib/realfi/stripe.ts uses the official stripe SDK:
verifyStripeWebhook→stripe.webhooks.constructEventdoes real HMAC signature verification of the raw body +Stripe-Signatureheader.processStripeEventmaps verified events to protocol actions:checkout.session.completed/charge.succeeded→ on-chain fiat receiptcharge.dispute.created→ chargeback signal
- Cred402 linkage rides in Checkout Session
metadata(seller_agent,operator_id,service_type,request_hash,result_hash).
PII and raw Stripe ids are hashed by the RealFi Bridge — never stored on-chain.
Wired into the running API (env-gated): POST /api/realfi/stripe-webhook reads
the raw body + Stripe-Signature header and verifies before committing;
POST /api/realfi/verify-bank runs the Plaid sandbox flow;
GET /api/x402/facilitator reports facilitator health/supported. Each returns
503 with a hint when its keys are unset, so sim mode never breaks.
stripe listen --forward-to localhost:4021/api/realfi/stripe-webhook
stripe trigger checkout.session.completed
test/realfi_stripe.test.ts proves it offline with real crypto: it generates
a valid signature via generateTestHeaderString, verifies it, and commits a real
on-chain fiat receipt — and asserts a forged signature is rejected.
2. Real Plaid (sandbox)
lib/realfi/plaid.ts uses the official plaid SDK against sandbox:
sandboxPublicTokenCreate → itemPublicTokenExchange → authGet + accountsBalanceGet,
then maps the response to a Bank Verification Envelope (bankVerificationFromPlaid,
a pure function) committed through the bridge. Gated by PLAID_CLIENT_ID /
PLAID_SECRET. Account/cashflow data is hashed; only the commitment goes on-chain.
test/realfi_plaid.test.ts covers the mapping and on-chain commitment offline.
3. Real cross-chain — Base Sepolia EVM satellite
The Solidity satellite suite (contracts/evm/) compiles for real under Foundry
(forge build → 16 files, Solc 0.8.24, via_ir). script/Deploy.s.sol deploys
and wires the full suite (EmergencyPause, SatelliteRegistry, AddressBindingMirror,
Receipt Outbox/Inbox, RWA/Evidence mirrors, CreditNoteVerifier, ExposureReporter,
CreditVault, Dispute + RealFi mirrors).
cd contracts/evm
forge install foundry-rs/forge-std # one-time (vendored, gitignored)
forge build # real compile
# Fund a Base Sepolia key (faucet), then deploy for real:
forge script script/Deploy.s.sol:Deploy --rpc-url base_sepolia --broadcast
foundry.toml defines the base_sepolia RPC endpoint (from BASE_SEPOLIA_RPC_URL).
Deploy inputs (PRIVATE_KEY, USDC_ADDRESS, CHAIN_CAIP2=eip155:84532) come from
.env. On Base Sepolia, USDC is 0x036CbD…CF7e.
The loop: the EVM Cred402ReceiptOutbox emits a ReceiptCreated event; the
Casper-root relayer (crosschain/relayers/, proven in test/relayer.test.ts)
builds a Universal Receipt Envelope + Merkle proof and anchors it to Casper's
ExternalReceiptRegistry. The work happens on Base; the trust settles on Casper —
exactly "Casper-rooted, chain-executed."
Status
| Rail | Real integration | Verified |
|---|---|---|
| Stripe | stripe SDK, real webhook HMAC verify → on-chain fiat receipt |
offline real-signature tests (4) |
| Plaid | plaid SDK sandbox → Bank Verification Envelope |
mapping + on-chain commit tests (3) |
| EVM satellite | Foundry compile + Base Sepolia deploy script | forge build green (16 files) |
| EVM→Casper anchor | Casper-root relayer + Merkle proof | test/relayer.test.ts |
All env-gated: with no Stripe/Plaid/Base keys, the protocol runs in sim/free mode
and the full test suite stays green. The legal/operating boundary for touching
real fiat flows is unchanged — see §7 of PRODUCTION.md.