x402 payments configuration settings.
| 356 | |
| 357 | |
| 358 | class X402Settings(BaseSettings): |
| 359 | """x402 payments configuration settings.""" |
| 360 | |
| 361 | model_config = SettingsConfigDict( |
| 362 | env_file=".env", |
| 363 | env_prefix="X402__", |
| 364 | extra="allow", |
| 365 | ) |
| 366 | |
| 367 | provider: str = "coinbase" |
| 368 | facilitator_url: str = "https://x402.org/facilitator" |
| 369 | default_network: str = "base-sepolia" |
| 370 | pay_to_env: str = "X402_PAY_TO" |
| 371 | max_timeout_seconds: int = 600 |
| 372 | |
| 373 | # Extension URI |
| 374 | extension_uri: str = "https://github.com/google-a2a/a2a-x402/v0.1" |
| 375 | |
| 376 | # Protected methods that require payment |
| 377 | # Similar to auth's public_endpoints, this defines which JSON-RPC methods need payment |
| 378 | protected_methods: list[str] = [ |
| 379 | "message/send", # Creating new tasks requires payment |
| 380 | # "message/stream", # Uncomment if streaming should require payment |
| 381 | ] |
| 382 | |
| 383 | # Metadata keys |
| 384 | meta_status_key: str = "x402.payment.status" |
| 385 | meta_required_key: str = "x402.payment.required" |
| 386 | meta_payload_key: str = "x402.payment.payload" |
| 387 | meta_receipts_key: str = "x402.payment.receipts" |
| 388 | meta_error_key: str = "x402.payment.error" |
| 389 | |
| 390 | # Status values |
| 391 | status_required: str = "payment-required" |
| 392 | status_submitted: str = "payment-submitted" |
| 393 | status_verified: str = "payment-verified" |
| 394 | status_completed: str = "payment-completed" |
| 395 | status_failed: str = "payment-failed" |
| 396 | |
| 397 | # RPC URLs by network — REMOVED in the x402 v2 migration. The v0.2.1 |
| 398 | # middleware connected to RPC providers directly for the on-chain |
| 399 | # `balanceOf` check; in v2 that responsibility moves to the facilitator |
| 400 | # (HTTPFacilitatorClient → /verify), so the resource server never makes |
| 401 | # an RPC call. Configuring RPC URLs here is now a no-op. If you need to |
| 402 | # change which facilitator answers /verify, set |
| 403 | # `app_settings.x402.facilitator_url` instead. |
| 404 | |
| 405 | # Operator-extensible mapping for EVM networks the x402 SDK doesn't ship |
| 406 | # with built-in metadata. See :class:`ExtraNetwork` for the per-entry |
| 407 | # contract. The default ships one example — SKALE Europa Hub via |
| 408 | # facilitator.x402.fi — so that "SKALE just works" out of the box |
| 409 | # *iff* the operator also sets ``facilitator_url`` to a SKALE-aware |
| 410 | # facilitator. The Coinbase default (``x402.org/facilitator``) does |
| 411 | # NOT support SKALE today. |
| 412 | extra_networks: dict[str, ExtraNetwork] = { |
| 413 | "skale-europa": ExtraNetwork( |
| 414 | caip2="eip155:1187947933", |
| 415 | asset="0x85889c8c714505E0c94b30fcfcF64fE3Ac8FCb20", |