x402-secure
Open-source x402 client SDKs for buyers and sellers that integrate with a unified gateway for risk session/trace and a seller proxy for verify/settle.
- Buyer SDK: create risk session/trace via
AGENT_GATEWAY_URL, buildX-PAYMENT-SECUREfrom OpenTelemetry context. - Seller SDK: call proxy
/x402/verifyand/x402/settlewith a simpleverify_then_settle(...)wrapper.
Fail-fast principles:
- Non-200 responses raise immediately (
HTTPStatusError). - Invalid or missing
traceparentcontext raises. - Header size limit enforced (
X-PAYMENT-SECURE≤ 4096 bytes).
Install
pip install x402-secure
Quickstart
import os, asyncio
from x402_secure_client import BuyerConfig, BuyerClient
async def main():
buyer = BuyerClient(BuyerConfig(
seller_base_url=os.getenv("SELLER_BASE_URL", "http://localhost:8010"),
agent_gateway_url=os.getenv("AGENT_GATEWAY_URL", "http://localhost:8000"),
network=os.getenv("NETWORK", "base-sepolia"),
buyer_private_key=os.getenv("BUYER_PRIVATE_KEY"),
))
# Create risk session + trace (single client!)
# agent_did: currently wallet address, future: EIP-8004 DID (did:eip8004:chain:contract:tokenId)
sid = (await buyer.create_risk_session(app_id=None, device={"ua": "oss-example"}))['sid']
tid = await buyer.store_agent_trace(
sid=sid,
task="Buy BTC price",
params={"symbol": "BTC/USD"},
environment={"network": os.getenv("NETWORK", "base-sepolia")},
)
# Execute payment with trace ID
res = await buyer.execute_paid_request(
endpoint="/api/market-data",
task="Buy BTC price",
params={"symbol": "BTC/USD"},
sid=sid,
tid=tid,
)
print(res)
asyncio.run(main())
See examples/ for runnable scripts.
License
Apache-2.0
Metadata
Release files for x402-secure 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| x402_secure-0.1.4.tar.gz | 162.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| x402_secure-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 175.4 kB
Release files / x402_secure-0.1.4.tar.gz
| Download URL | x402_secure-0.1.4.tar.gz |
|---|---|
| Size | 162.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42c5c412e6b34247ffe4163bb3da0405bd78f5b9acd44634e1de92af132ad52e
|
|
BLAKE2b-256 checksum How to use checksums |
944cc1b9d3c82552a09e50b5945cbfd8a895062e3c1f8f9f14f3a96e1c4f650b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / x402_secure-0.1.4-py3-none-any.whl
| Download URL | x402_secure-0.1.4-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a175ebd7a708d80ef15677606c16eec8843e69c4186c08670eb7fb52fff5a92
|
|
BLAKE2b-256 checksum How to use checksums |
f4b045f61b0877e81c1e1239ad997d497520e6dfc39df72cc0c34904fa0badfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for x402-secure 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.