Class: FacilitatorClient
Defined in: packages/x402-client/src/facilitator.ts:69
Thin client for a Canton x402 facilitator's verify / settle / supported API.
Constructors
Constructor
new FacilitatorClient(facilitatorUrl, opts?): FacilitatorClient;Defined in: packages/x402-client/src/facilitator.ts:80
Parameters
facilitatorUrl
string
Base URL of the facilitator; a trailing slash is trimmed.
opts?
Optional API key + request timeout.
Returns
FacilitatorClient
Methods
settle()
settle(payload, requirements): Promise<
| {
amount?: string;
extensions?: {
[key: string]: unknown;
};
network: string;
payer?: string;
success: true;
transaction: string;
}
| {
errorMessage?: string;
errorReason: | "invalid_exact_canton_missing_proof"
| "invalid_exact_canton_malformed_payload"
| "invalid_exact_canton_signature_invalid"
| "invalid_exact_canton_amount_mismatch"
| "invalid_exact_canton_merchant_mismatch"
| "invalid_exact_canton_instrument_id_mismatch"
| "invalid_exact_canton_preapproval_missing"
| "invalid_exact_canton_fee_payer_mismatch"
| "invalid_exact_canton_expired"
| "invalid_exact_canton_execute_before_too_far"
| "invalid_exact_canton_insufficient_inputs"
| "invalid_exact_canton_memo_mismatch"
| "invalid_exact_canton_merchant_not_registered"
| "invalid_exact_canton_self_payment"
| "invalid_exact_canton_execute_failed"
| "unexpected_canton_ledger_error"
| "settlement_pending"
| "invalid_network"
| "unsupported_scheme"
| "insufficient_funds"
| "invalid_payload"
| "invalid_payment_requirements"
| "invalid_scheme"
| "invalid_x402_version"
| "invalid_transaction_state"
| "unexpected_verify_error"
| "unexpected_settle_error"
| "invalid_exact_canton_synchronizer_mismatch";
extensions?: {
[key: string]: unknown;
};
network: string;
payer?: string;
success: false;
transaction: string;
}>;Defined in: packages/x402-client/src/facilitator.ts:106
POST /v2/settle — execute the prepared transfer on-ledger. Resolves with the outcome the facilitator answers with 2xx: a success, a failure, or settlement_pending (relayed, outcome not known yet; transaction names it). Throws FacilitatorError on any other status or a transport error.
Parameters
payload
X402PaymentPayload<unknown>
requirements
X402PaymentRequirements<unknown>
Returns
Promise< | { amount?: string; extensions?: { [key: string]: unknown; }; network: string; payer?: string; success: true; transaction: string; } | { errorMessage?: string; errorReason: | "invalid_exact_canton_missing_proof" | "invalid_exact_canton_malformed_payload" | "invalid_exact_canton_signature_invalid" | "invalid_exact_canton_amount_mismatch" | "invalid_exact_canton_merchant_mismatch" | "invalid_exact_canton_instrument_id_mismatch" | "invalid_exact_canton_preapproval_missing" | "invalid_exact_canton_fee_payer_mismatch" | "invalid_exact_canton_expired" | "invalid_exact_canton_execute_before_too_far" | "invalid_exact_canton_insufficient_inputs" | "invalid_exact_canton_memo_mismatch" | "invalid_exact_canton_merchant_not_registered" | "invalid_exact_canton_self_payment" | "invalid_exact_canton_execute_failed" | "unexpected_canton_ledger_error" | "settlement_pending" | "invalid_network" | "unsupported_scheme" | "insufficient_funds" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "unexpected_verify_error" | "unexpected_settle_error" | "invalid_exact_canton_synchronizer_mismatch"; extensions?: { [key: string]: unknown; }; network: string; payer?: string; success: false; transaction: string; }>
supported()
supported(opts?): Promise<{
extensions: string[];
kinds: object[];
signers: {
[key: string]: string[];
};
}>;Defined in: packages/x402-client/src/facilitator.ts:134
GET /v2/supported — what this facilitator settles: the (scheme, network) kinds and, in kinds[].extra, the synchronizer, instruments and transfer methods a merchant configures from. Unauthenticated.
Cached for FacilitatorClientOptions.supportedTtlMs. Concurrent callers share one request rather than each making their own, so a cold start under load costs one round trip and not one per caller.
When the TTL has passed and the refetch fails, the last value is served instead: these are near-static deployment facts, and a facilitator blip should not stop a merchant quoting. With nothing cached to fall back to, the error propagates.
{ refresh: true } bypasses the cache on the way in and on the way out: a caller asking for current data is told when it cannot have it, so a failed refresh throws rather than resolving with the old value.
Each caller gets its own copy, so editing the result cannot change what the next caller reads.
Parameters
opts?
refresh?
boolean
Returns
Promise<{ extensions: string[]; kinds: object[]; signers: { [key: string]: string[]; }; }>
verify()
verify(payload, requirements): Promise<
| {
extensions?: {
[key: string]: unknown;
};
extra?: {
[key: string]: unknown;
};
isValid: true;
payer?: string;
}
| {
extensions?: {
[key: string]: unknown;
};
extra?: {
[key: string]: unknown;
};
invalidMessage?: string;
invalidReason: | "invalid_exact_canton_missing_proof"
| "invalid_exact_canton_malformed_payload"
| "invalid_exact_canton_signature_invalid"
| "invalid_exact_canton_amount_mismatch"
| "invalid_exact_canton_merchant_mismatch"
| "invalid_exact_canton_instrument_id_mismatch"
| "invalid_exact_canton_preapproval_missing"
| "invalid_exact_canton_fee_payer_mismatch"
| "invalid_exact_canton_expired"
| "invalid_exact_canton_execute_before_too_far"
| "invalid_exact_canton_insufficient_inputs"
| "invalid_exact_canton_memo_mismatch"
| "invalid_exact_canton_merchant_not_registered"
| "invalid_exact_canton_self_payment"
| "invalid_exact_canton_execute_failed"
| "unexpected_canton_ledger_error"
| "settlement_pending"
| "invalid_network"
| "unsupported_scheme"
| "insufficient_funds"
| "invalid_payload"
| "invalid_payment_requirements"
| "invalid_scheme"
| "invalid_x402_version"
| "invalid_transaction_state"
| "unexpected_verify_error"
| "unexpected_settle_error"
| "invalid_exact_canton_synchronizer_mismatch";
isValid: false;
payer?: string;
}>;Defined in: packages/x402-client/src/facilitator.ts:92
POST /v2/verify — dry-run validation without settling. Resolves with the verdict (isValid true or false); throws FacilitatorError only on a protocol/transport error.
Parameters
payload
X402PaymentPayload<unknown>
requirements
X402PaymentRequirements<unknown>
Returns
Promise< | { extensions?: { [key: string]: unknown; }; extra?: { [key: string]: unknown; }; isValid: true; payer?: string; } | { extensions?: { [key: string]: unknown; }; extra?: { [key: string]: unknown; }; invalidMessage?: string; invalidReason: | "invalid_exact_canton_missing_proof" | "invalid_exact_canton_malformed_payload" | "invalid_exact_canton_signature_invalid" | "invalid_exact_canton_amount_mismatch" | "invalid_exact_canton_merchant_mismatch" | "invalid_exact_canton_instrument_id_mismatch" | "invalid_exact_canton_preapproval_missing" | "invalid_exact_canton_fee_payer_mismatch" | "invalid_exact_canton_expired" | "invalid_exact_canton_execute_before_too_far" | "invalid_exact_canton_insufficient_inputs" | "invalid_exact_canton_memo_mismatch" | "invalid_exact_canton_merchant_not_registered" | "invalid_exact_canton_self_payment" | "invalid_exact_canton_execute_failed" | "unexpected_canton_ledger_error" | "settlement_pending" | "invalid_network" | "unsupported_scheme" | "insufficient_funds" | "invalid_payload" | "invalid_payment_requirements" | "invalid_scheme" | "invalid_x402_version" | "invalid_transaction_state" | "unexpected_verify_error" | "unexpected_settle_error" | "invalid_exact_canton_synchronizer_mismatch"; isValid: false; payer?: string; }>