x402-cli — one-shot BankofAI x402 CLI: serve a 402 payment endpoint, or pay one as a client.
Project description
x402-cli (Python)
One-shot BankofAI x402 CLI built on top of the bankofai-x402 SDK. Three commands:
serve— start a local x402 payment server (advertises payment terms, accepts a signed payload, settles).pay <url>— pay an x402-protected URL when the server returns402 Payment Required.roundtrip— one-shot test: spin upservein the background, runpayagainst it, shut down.
Full flag matrix and example output: FEATURES.md.
Install
pip install bankofai-x402-cli
x402-cli --help
Or from source:
cd x402-cli
pip install -e .
x402-cli --help
Amount conventions
Two mutually exclusive forms are accepted everywhere a price is taken:
rawAmount = amount × 10^decimals
| Flag | Meaning | Example (USDT, 6 decimals) |
|---|---|---|
--amount <decimal> |
Human-readable | 1.25 |
--rawAmount <integer> |
Smallest on-chain unit | 1250000 |
Pay-side caps mirror the same split: --max-amount (human-readable) / --max-rawAmount (smallest unit).
Quick start
# Start a server that charges 1.25 USDT on TRON Nile
x402-cli serve --pay-to TJWdoJk8KyrfxZ2iDUqz7fwpXaMkNqPehx \
--amount 1.25 --network tron:nile
# In another shell — pay it (cap human-readable)
x402-cli pay http://127.0.0.1:4020/pay \
--max-amount 1.25 --network tron:nile --token USDT
# Or one-shot end-to-end on a single line
x402-cli roundtrip --pay-to TJWdoJk8KyrfxZ2iDUqz7fwpXaMkNqPehx \
--amount 1.25 --network tron:nile --token USDT
Design
Unlike the TypeScript version which implements its own HTTP server and facilitator client, the Python CLI directly uses the SDK's X402Server and FacilitatorClient from bankofai-x402:
from bankofai.x402.server import X402Server
from bankofai.x402.facilitator import FacilitatorClient
server = X402Server() # No duplication
facilitator = FacilitatorClient(base_url) # SDK provided
This avoids code duplication and keeps the CLI thin (just argument parsing + output formatting).
Environment variables
| Var | Purpose |
|---|---|
TRON_PRIVATE_KEY |
TRON wallet key for --wallet env |
EVM_PRIVATE_KEY |
EVM wallet key for --wallet env |
TRON_GRID_API_KEY |
Optional, forwarded to SDK for TronGrid |
FACILITATOR_URL |
Override facilitator endpoint (default https://facilitator.bankofai.io) |
Development
cd x402-cli
pip install -e .[dev]
pytest
x402-cli --help
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 Distribution
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 bankofai_x402_cli-0.1.0b9.tar.gz.
File metadata
- Download URL: bankofai_x402_cli-0.1.0b9.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b4d22f45e925e079e6b4ba4af1a1fc1a111c17526e9c23439cee83873fa30d
|
|
| MD5 |
254d021fbbbf6d55d4180dd3fa6ff1c4
|
|
| BLAKE2b-256 |
cdac9e471a9fdc1f19e4b9744e6929743f7614c618cc138a2a2892bbeb2e5308
|
File details
Details for the file bankofai_x402_cli-0.1.0b9-py3-none-any.whl.
File metadata
- Download URL: bankofai_x402_cli-0.1.0b9-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4e6ebb3df6ba18563c2beabb494e342d5019f272cfe3b808368c53e288fb9fe
|
|
| MD5 |
2296e12cfc9edf84b25b799506f049de
|
|
| BLAKE2b-256 |
11a2d06bae15de7732643dbaace345f84dd1811e57d2e75a73e8c43804a18be4
|