Skip to content

Commit 9beea02

Browse files
author
Rotwang9000
committed
x402: switch default facilitator to openx402.ai + initialise eagerly
Two boot-time gotchas surfaced once we lit the paywall against a real Base-mainnet recipient: 1. The public x402.org/facilitator only services testnets — its /supported manifest does not list eip155:8453. On mainnet boot the middleware throws RouteConfigurationError:missing_facilitator. Switch the default in config.js to OpenX402's permissionless mainnet facilitator (no API key, supports Base USDC with the canonical EIP-712 metadata). 2. syncFacilitatorOnStart was wired to false "for boot speed". Without the boot-time /supported fetch, the resource server has no registered schemes and "Facilitator does not support exact on eip155:8453" is thrown at request time — much harder to spot. Pass true explicitly and document why above the call. 108/108 tests still green.
1 parent 21939b2 commit 9beea02

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ export const config = Object.freeze({
7272
x402Enabled: asString('X402_ENABLED', '') === '1',
7373
x402Network: asString('X402_NETWORK', 'eip155:8453'),
7474
x402RecipientAddress: asString('X402_RECIPIENT_ADDRESS', ''),
75-
x402FacilitatorUrl: asString('X402_FACILITATOR_URL', 'https://x402.org/facilitator'),
75+
// Mainnet facilitator. The public x402.org/facilitator only services
76+
// testnets (Base Sepolia / Solana Devnet / etc.) — using it on
77+
// eip155:8453 yields "Facilitator does not support exact" at boot.
78+
// OpenX402 is permissionless, no API key, supports Base mainnet
79+
// USDC with proper EIP-712 metadata. Override at any time via
80+
// X402_FACILITATOR_URL.
81+
x402FacilitatorUrl: asString('X402_FACILITATOR_URL', 'https://facilitator.openx402.ai'),
7682
// Price per call for each premium endpoint, expressed in the x402
7783
// Money format ("$0.05" = 5 ¢). The facilitator quotes the USDC
7884
// atomic amount on Base from this.

src/x402.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,20 @@ export async function registerX402(app, x402Cfg) {
142142
]);
143143
const facilitatorClient = new HTTPFacilitatorClient({ url: x402Cfg.facilitatorUrl });
144144
const schemes = [{ network: x402Cfg.network, server: new ExactEvmScheme() }];
145+
// `syncFacilitatorOnStart: true` is required — it fetches the
146+
// /supported manifest from the facilitator so the resource server
147+
// knows which (scheme, network) tuples it can issue
148+
// PaymentRequirements for. Without it the middleware throws on
149+
// the first 402-eligible request: "Facilitator does not support
150+
// exact on eip155:8453".
145151
paymentMiddlewareFromConfig(
146152
app,
147153
x402Cfg.routes,
148154
facilitatorClient,
149155
schemes,
150156
/* paywallConfig */ undefined,
151157
/* paywall */ undefined,
152-
/* syncFacilitatorOnStart */ false
158+
/* syncFacilitatorOnStart */ true
153159
);
154160
}
155161

0 commit comments

Comments
 (0)