Official Cronos X402 Facilitator Python SDK
Project description
Cronos X402 Facilitator SDK for Python
The Cronos Facilitator Python SDK provides a lightweight, strongly typed client for interacting with the Cronos X402 Facilitator API.
It enables Python applications to:
- Generate EIP-3009 signed payment headers
- Build X402 Payment Requirements
- Submit payments for verification and settlement
- Discover supported networks and capabilities
This SDK supports fully automated off-chain authorization / on-chain execution payment flows on Cronos Mainnet and Cronos Testnet.
Features
-
Facilitator API Client
/supported/verify/settle
-
EIP-3009 Payment Header Generator
- Produces Base64-encoded X402 headers
-
Typed X402 Payment Requirements
- JSON-serializable and schema-aware
-
Minimal dependencies
- Uses
requestsandeth-accountonly when required
- Uses
-
Cronos-native
- Supports Cronos Mainnet and Cronos Testnet
Installation
pip install crypto_com_facilitator_client
Note EIP-3009 signing requires optional dependencies:
pip install eth-account hexbytes
Usage
1. Create a Facilitator Client
The Facilitator base URL is fixed internally and cannot be overridden.
from crypto_com_facilitator_client import Facilitator
from crypto_com_facilitator_client.integrations.facilitator_interface import CronosNetwork
facilitator = Facilitator(
network=CronosNetwork.CronosTestnet # or CronosMainnet
)
2. Generate Payment Requirements
requirements = facilitator.generate_payment_requirements(
pay_to="0xRecipientAddress",
description="Payment for Order #123",
max_amount_required="1000000", # base units
)
print(requirements)
3. Generate a Base64 Payment Header (EIP-3009)
import os
from eth_account import Account
signer = Account.from_key(os.environ["PRIVATE_KEY"])
header = await facilitator.generate_payment_header(
to="0xRecipientAddress",
value="1000000", # 1 USDCe (6 decimals)
signer=signer,
valid_before=int(time.time()) + 600, # 10 min expiry
)
print("header:", header)
4. Verify a Payment Request
body = facilitator.build_verify_request(header, requirements)
verify_response = await facilitator.verify_payment(body)
print("verify:", verify_response)
5. Settle a Verified Payment
settle_response = await facilitator.settle_payment(body)
print("settled:", settle_response)
6. Discover Supported Networks & Capabilities
capabilities = await facilitator.get_supported()
print(capabilities)
End-to-End Example (Full Flow)
from crypto_com_facilitator_client import Facilitator
from crypto_com_facilitator_client.integrations.facilitator_interface import CronosNetwork
from eth_account import Account
import os
import time
facilitator = Facilitator(network=CronosNetwork.CronosTestnet)
signer = Account.from_key(os.environ["PRIVATE_KEY"])
receiver = "0xRecipientAddress"
header = await facilitator.generate_payment_header(
to=receiver,
value="1000000",
signer=signer,
)
requirements = facilitator.generate_payment_requirements(
pay_to=receiver,
description="Premium API access",
max_amount_required="1000000",
)
body = facilitator.build_verify_request(header, requirements)
verify = await facilitator.verify_payment(body)
if verify.get("isValid"):
settle = await facilitator.settle_payment(body)
print("Transaction hash:", settle.get("txHash"))
API Overview
Facilitator Client
| Method | Description |
|---|---|
get_supported() |
Returns supported networks and capabilities |
verify_payment(request) |
Validates the Base64 header + requirements |
settle_payment(request) |
Executes the authorized transfer on-chain |
build_verify_request(header, requirements) |
Helper to produce valid verification/settlement payloads |
Utilities
| Function | Description |
|---|---|
generate_cronos_payment_header() |
Creates Base64 EIP-3009 payment header |
generate_payment_requirements() |
Produces typed X402 Payment Requirements |
Supported Networks
- Cronos Mainnet
- Cronos Testnet
License
MIT © 2025 Crypto.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crypto_com_facilitator_client-1.0.3-py3-none-any.whl.
File metadata
- Download URL: crypto_com_facilitator_client-1.0.3-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4f77bfeed184bdde58e09c50d6e32cb2ba5c03a403e814ee086db614eb71dae
|
|
| MD5 |
b81c0bd878deb17ba0a41508ec7dd61d
|
|
| BLAKE2b-256 |
f4479ac6f38467a8174efa0668dc4662865b53ffe7b87c6015e509004f120eef
|