Skip to main content

x402 Payment Protocol SDK for Python

Project description

x402

Python SDK for the x402 payment protocol — supports TRON and EVM (BSC) networks.

Compatibility Notes

  • The EVM exact flow is being aligned to the Coinbase x402 v2 payload shape.
  • Exact transfer authorizations are represented in payload.authorization.
  • Server-side migration fallback still accepts the legacy extensions.transferAuthorization field while the spec-aligned path becomes primary.

Installation

pip install bankofai-x402

Optional extras:

pip install "bankofai-x402[tron]"
pip install "bankofai-x402[fastapi]"
pip install "bankofai-x402[flask]"
pip install "bankofai-x402[all]"

Quick Start

from bankofai.x402.clients import X402Client

client = X402Client()

If you want automatic handling of HTTP 402 responses, use X402HttpClient:

import httpx

from bankofai.x402.clients import X402Client, X402HttpClient

x402_client = X402Client()
http_client = httpx.AsyncClient()
client = X402HttpClient(http_client=http_client, x402_client=x402_client)

BSC Testnet Example

For a complete BSC testnet exact smoke example, including a local-private-key client and a server that advertises DHLU for ERC-3009, see examples/bsc-testnet-smoke/README.md.

The key point for BSC exact is that the advertised asset must actually support transferWithAuthorization. The smoke-tested path in this repository uses DHLU on eip155:97.

Supported Schemes

  • exact_permit: Standard x402 payment scheme using TIP-712/EIP-712 permits.
  • exact_gasfree: (TRON) Pay with USDT/USDD without TRX gas using the GasFree protocol.
  • exact: (EVM) Native direct payment using ERC-3009.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bankofai_x402-0.6.0.tar.gz (12.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bankofai_x402-0.6.0-py3-none-any.whl (97.9 kB view details)

Uploaded Python 3

File details

Details for the file bankofai_x402-0.6.0.tar.gz.

File metadata

  • Download URL: bankofai_x402-0.6.0.tar.gz
  • Upload date:
  • Size: 12.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bankofai_x402-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d119613e996b5eccf90c7b77b36050ba476229395c45de3a1e838afa2f3ff93f
MD5 11a45d8e56ede1e0ef39ff2af040e7e0
BLAKE2b-256 a53fefeffc0f7fd1c5607bedfdf1339f9a6846ddf1a26f4ae88e0c1d472052d6

See more details on using hashes here.

File details

Details for the file bankofai_x402-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: bankofai_x402-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 97.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bankofai_x402-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b12448d809d10ffb0613d927974acccb276d577abd039199734b5c3df2da75a3
MD5 40c98a7711a4278c0def0484b70f0c77
BLAKE2b-256 35a941fbf2aaff186ad486269b2179134f751f1a846ce89f11a1619e8f587651

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page