Express.js JavaScript server acting as a BCH x402 Facilitator
x402-bch-facilitator is an early-stage JavaScript project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
This directory contains the reference Facilitator service for the Bitcoin Cash adaptation of the x402 protocol. The facilitator (bch-facilitator.js) provides the /facilitator REST endpoints that Servers call to verify BCH payments and maintain prepaid UTXO balances, as described in the core x402 specification and the BCH-focused x402-bch specification v2.1.
Protocol Version: This facilitator supports x402-bch v2 protocol with backward compatibility for v1 requests.
402 responses, and forward the client’s payment payload plus requirements to the Facilitator.This example implements the Facilitator role. It exposes the canonical /facilitator/supported, /facilitator/verify, and /facilitator/settle endpoints so Servers can outsource BCH-specific validation while still receiving funds directly on-chain.
utxo scheme defined in the specification, including signature checks and UTXO-based debit tracking.minimal-slp-wallet plus a retry queue to query BCH infrastructure and validate funding transactions.minimal-slp-wallet:consumer-api (ipfs-bch-wallet-service), orrest-api (bch-api, required for Double Spend Proof support).cd x402/x402-bch/examples/facilitator
npm install
Copy .env-local to .env and adjust as needed. Key variables:
PORT: HTTP port for the facilitator (default 4345).SERVER_BCH_ADDRESS: Cash address that must receive the funding UTXO.API_TYPE: BCH backend interface (consumer-api or rest-api).BCH_SERVER_URL: URL for the BCH infrastructure node or consumer service.LOG_LEVEL: Logging verbosity (info, debug, etc.).Example:
cp .env-local .env
Then edit .env to point at your BCH infrastructure and server address.
npm start
The service starts an Express server (see bin/server.js) and exposes:
GET /health – simple health probe.GET / – welcome payload listing supported facilitator endpoints.GET /facilitator/supported – announces supported payment kinds in v2 format with x402Version: 2, scheme: 'utxo', CAIP-2 network identifiers, extensions, and signers.POST /facilitator/verify – validates a BCH payment payload against advertised requirements, updates the ledger, and returns { isValid, payer, invalidReason?, remainingBalanceSat?, ledgerEntry? }.POST /facilitator/settle – optional reconciliation step that replays verify and returns settlement metadata with CAIP-2 network format.Logs include every incoming request plus wallet validation details. LevelDB state is stored in ./leveldb/utxo.
utxo scheme and BCH network (supports both v1 'bch' format and v2 CAIP-2 format 'bip122:000000000000000000651ef99cb9fcbe').JSON.stringify(authorization) and calls BitcoinCash.verifyMessage.SERVER_BCH_ADDRESS, and computes the satoshi value.minAmountRequired and v2 amount fields) from the stored balance, rejecting if insufficient to cover the call.This mirrors the flow in the x402-bch specification v2.1 and allows a single on-chain payment to authorize multiple paid HTTP requests.
This facilitator supports x402-bch v2 protocol with the following features:
bip122:000000000000000000651ef99cb9fcbe for BCH mainnet (backward compatible with v1 'bch' format)accepted field (backward compatible with v1 top-level scheme/network)amount field and v1 minAmountRequired fieldremainingBalanceSat and ledgerEntry fieldsThe facilitator automatically detects and handles both v1 and v2 request formats, ensuring seamless compatibility during migration periods.
/facilitator/verify before returning protected data, and the client will automatically retry with BCH payment headers.PAYMENT_AMOUNT_SATS and pricing in the server example to observe the ledger decrementing remaining satoshis.insufficient_utxo_balance: Fund a new UTXO or lower the cost per request.API_TYPE to rest-api (bch-api) for Double Spend Proof support./facilitator/verify endpoint now returns ledger snapshots (remainingBalanceSat, ledgerEntry) as per v2 specification.{
"kinds": [
{
"x402Version": 2,
"scheme": "utxo",
"network": "bip122:000000000000000000651ef99cb9fcbe"
}
],
"extensions": [],
"signers": {
"bip122:*": []
}
}
Request:
{
"x402Version": 2,
"paymentPayload": {
"x402Version": 2,
"accepted": {
"scheme": "utxo",
"network": "bip122:000000000000000000651ef99cb9fcbe",
"amount": "1000",
"payTo": "bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d"
},
"payload": {
"signature": "...",
"authorization": {
"from": "bitcoincash:qz9s2mccqamzppfq708cyfde5ejgmsr9hy7r3unmkk",
"to": "bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d",
"value": "1000",
"txid": "...",
"vout": 0,
"amount": "2000"
}
}
},
"paymentRequirements": {
"scheme": "utxo",
"network": "bip122:000000000000000000651ef99cb9fcbe",
"amount": "1000",
"payTo": "bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d"
}
}
Response:
{
"isValid": true,
"payer": "bitcoincash:qz9s2mccqamzppfq708cyfde5ejgmsr9hy7r3unmkk",
"remainingBalanceSat": "9000",
"ledgerEntry": {
"utxoId": "txid:0",
"transactionValueSat": "20000",
"totalDebitedSat": "11000",
"lastUpdated": "2025-11-08T17:05:42.000Z"
}
}
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.
Accept payments from AI agents. Open-source. Your data, your domain, your rules. Free forever.
A production-ready payment settlement service for the x402 protocol. Built with Elysia and Node.js, it verifies cryptographic payment signatures and settles transactions on-chain for EVM, SVM (Solana), and Starknet networks.
Golang implementation of an x402 payment facilitator
x402 payment facilitator — verifies and settles EIP-3009 USDC micropayments on Base, Arbitrum, and Ethereum.