import type { FacilitatorHandler } from "@faremeter/types/facilitator"
export async function createMyFacilitatorHandler(
network: string,
rpcUrl: string,
signerKey: string,
): Promise<FacilitatorHandler> {
const client = createChainClient(rpcUrl, signerKey)
return {
getSupported: () => [
Promise.resolve({
x402Version: 2,
scheme: "my-scheme",
network,
}),
],
getRequirements: async ({ accepts }) => {
// Enrich requirements with chain-specific fields
return accepts
.filter((r) => r.scheme === "my-scheme" && r.network === network)
.map((r) => ({
...r,
// Add facilitator-specific enrichment here
extra: { signerAddress: client.address },
}))
},
handleSettle: async (requirements, payment) => {
if (requirements.scheme !== "my-scheme") return null
// Verify and submit the transaction on-chain
const txHash = await client.submitTransaction(payment.payload)
return {
success: true,
transaction: txHash,
network,
}
},
}
}