Metadata-Version: 2.1
Name: bankofai-x402
Version: 0.5.9
Summary: x402 Payment Protocol SDK for Python
Project-URL: Homepage, https://github.com/BofAI/x402
Project-URL: Documentation, https://github.com/BofAI/x402#readme
Project-URL: Repository, https://github.com/BofAI/x402
Author-email: x402 <dev@x402.io>
License: MIT
Keywords: blockchain,payment,tron,x402
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: bankofai-agent-wallet>=2.3.0
Requires-Dist: base58>=2.1.1
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: all
Requires-Dist: eth-account>=0.8.0; extra == 'all'
Requires-Dist: fastapi>=0.100.0; extra == 'all'
Requires-Dist: flask>=2.0.0; extra == 'all'
Requires-Dist: tronpy>=0.4.0; extra == 'all'
Requires-Dist: web3>=6.0.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: evm
Requires-Dist: eth-account>=0.8.0; extra == 'evm'
Requires-Dist: web3>=6.0.0; extra == 'evm'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100.0; extra == 'fastapi'
Provides-Extra: flask
Requires-Dist: flask>=2.0.0; extra == 'flask'
Provides-Extra: tron
Requires-Dist: tronpy>=0.4.0; extra == 'tron'
Description-Content-Type: text/markdown

# 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

```bash
pip install bankofai-x402
```

Optional extras:

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

## Quick Start

```python
from bankofai.x402.clients import X402Client

client = X402Client()
```

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

```python
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`](../../../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

- Repository: https://github.com/BofAI/x402
- Issues: https://github.com/BofAI/x402/issues
- Documentation: https://docs.bankofai.io/
- Contributing: [CONTRIBUTING.md](../../CONTRIBUTING.md)
