Skip to main content

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 returns 402 Payment Required.
  • roundtrip — one-shot test: spin up serve in the background, run pay against it, shut down.

Full flag matrix and example output: FEATURES.md. Hands-on walkthrough (TRON GasFree + TRON/BSC permit, copy-paste commands): docs/manual-test-guide.md.

Install

pip install bankofai-x402-cli
x402-cli --help

Or from source:

cd x402-cli
pip install -e .
x402-cli --help

Wallet

Signing is delegated to bankofai-agent-wallet (transitive dep). It picks up either an encrypted local wallet (managed by the agent-wallet CLI) or a private-key / mnemonic env var. One key derives both EVM and TRON addresses — there is no --wallet flag, just install once and x402-cli picks the wallet up automatically.

Setup steps and full env var list: agent-wallet — Getting Started.

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

Schemes

Auto-selected per (network, token) from a small registry; override with --scheme <name>.

Network Token Default Why
eip155:56 / eip155:97 (BSC) USDT, USDC exact_permit EIP-2612
eip155:97 (BSC Testnet) DHLU exact ERC-3009
tron:mainnet / tron:nile / tron:shasta USDT, USDD exact_gasfree Hosted exact_permit settlement can verify the signature but still revert during on-chain permitTransferFrom; GasFree relays through a custodial address. Override with --scheme exact_permit if you've hardened the path.

Environment variables

Var Purpose
AGENT_WALLET_PRIVATE_KEY / TRON_PRIVATE_KEY Wallet private key, picked up by agent-wallet's env provider
AGENT_WALLET_MNEMONIC / TRON_MNEMONIC Alternative: BIP-39 mnemonic (with optional _ACCOUNT_INDEX)
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


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_cli-0.1.0b11.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

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

bankofai_x402_cli-0.1.0b11-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file bankofai_x402_cli-0.1.0b11.tar.gz.

File metadata

  • Download URL: bankofai_x402_cli-0.1.0b11.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bankofai_x402_cli-0.1.0b11.tar.gz
Algorithm Hash digest
SHA256 e081bdc295fdcd62ac4a5f9185da8f146356b0d381066f76178d1f94ed2d810f
MD5 761a47a834be111c8587f15d078dabd0
BLAKE2b-256 afe3d66323155abbab468ce2e03566d1e145973e3e6742e1efe377885876cde1

See more details on using hashes here.

File details

Details for the file bankofai_x402_cli-0.1.0b11-py3-none-any.whl.

File metadata

File hashes

Hashes for bankofai_x402_cli-0.1.0b11-py3-none-any.whl
Algorithm Hash digest
SHA256 de3dd90def7166523b2c5bf417960527be60938066337b0f5a28c2289ca98184
MD5 1437eae2307c31ff8f444c3a64e34ae2
BLAKE2b-256 530d3be613be306be712eed8bb6b1bfe4fdadf914cfd29c614289e2a0e096bb1

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