This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is consensus-facilitator — the x402 payment facilitator for the Consensus Protocol. It verifies and settles x402 payments across ICP, EVM (mainnet + Base + testnets), and SVM (mainnet + devnet). The Consensus orchestrator reaches it via FACILITATOR_URL.
Canonical cross-repo reference: the architecture + cross-repo contracts live in consensus-docs → https://docs.consensus.canister.software/protocol/architecture/ (source). Read it before changing the verify/settle API or the scheme/network identifiers — those are a contract with consensus (server x402ResourceServer) and consensus-client. Related repos: consensus (orchestrator), consensus-client (SDK + CLI), consensus-node (worker-node runtime), consensus-docs (docs).
Node + TypeScript (tsx for dev, tsc for the build); PM2 in production.
npm install
npm run dev # tsx watch src/index.ts
npm run build # tsc → dist/
npm start # node dist/index.js
npm run typecheck # tsc --noEmit
npm run lint # eslint src/PM2: npm run pm2:start | pm2:stop | pm2:restart | pm2:logs | pm2:status (see ecosystem.config.cjs).
Fastify HTTP server (src/index.ts) exposing the x402 facilitator API (verify + settle). Logic is split per network:
src/icp/— ICP scheme:agent,identity,ledger,codec,verify,scheme,nonces. Uses@dfinity/*+@icp-sdk/core.- EVM + SVM verification/settlement via
@x402/evmand@x402/svm(withviemand@solana/kit). src/config.ts— network + key configuration.src/db.ts—better-sqlite3persistence (e.g. nonce tracking).src/types.ts— shared types.
- ESM, TypeScript strict.
tsxfor dev,tscfor thedist/build. - Default branch is
master(the other Consensus repos usemain). - Keep real keys out of git —
src/icp/test-x402.pemis a test identity only. - Keep scheme/network identifiers (EVM
eip155:*, SVMsolana:*, ICPicp:*) aligned with the server and client; see the canonical reference.