Metadata-Version: 2.4
Name: openclaw-x402
Version: 0.1.0
Summary: Drop-in x402 payment middleware for Flask APIs. Machine-to-machine payments on Base chain.
Author-email: Elyan Labs <scott@elyanlabs.ai>
License-Expression: MIT
Project-URL: Homepage, https://rustchain.org/wallets.html
Project-URL: Repository, https://github.com/Scottcjn/Rustchain
Keywords: x402,openclaw,payments,flask,coinbase,base-chain,usdc,wrtc,ai-agent,machine-to-machine
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Framework :: Flask
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: flask>=2.0
Provides-Extra: coinbase
Requires-Dist: x402[flask]; extra == "coinbase"
Requires-Dist: coinbase-agentkit>=0.1.0; extra == "coinbase"
Dynamic: license-file

# openclaw-x402

Drop-in x402 payment middleware for Flask APIs. Add machine-to-machine payments to any OpenClaw platform in 5 lines.

## Install

```bash
pip install openclaw-x402
```

## Quick Start

```python
from flask import Flask, jsonify
from openclaw_x402 import X402Middleware

app = Flask(__name__)
x402 = X402Middleware(app, treasury="0xYourBaseAddress")

@app.route("/api/premium/data")
@x402.premium(price="10000", description="Premium data export")  # $0.01 USDC
def premium_data():
    return jsonify({"data": "your premium content"})

# Free endpoints work normally — no decorator needed
@app.route("/api/public/data")
def public_data():
    return jsonify({"data": "free content"})
```

## How It Works

1. Agent hits your premium endpoint
2. Gets back HTTP 402 with payment instructions (USDC amount, treasury address, facilitator URL)
3. Agent pays via Coinbase wallet on Base chain
4. Agent retries with `X-PAYMENT` header containing tx hash
5. Middleware verifies payment via Coinbase facilitator
6. Access granted

## Free Mode

Set `price="0"` to pass all requests through without payment — useful for testing the flow before charging.

```python
@x402.premium(price="0", description="Free for now")
def free_premium():
    return jsonify({"data": "free during testing"})
```

## Configuration

| Env Var | Purpose |
|---------|---------|
| `CDP_API_KEY_NAME` | Coinbase Developer Platform API key name |
| `CDP_API_KEY_PRIVATE_KEY` | CDP API private key |

Get credentials at [portal.cdp.coinbase.com](https://portal.cdp.coinbase.com).

## Contract Addresses (Base Mainnet)

| Token | Address |
|-------|---------|
| USDC | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
| wRTC | `0x5683C10596AaA09AD7F4eF13CAB94b9b74A669c6` |
| Aerodrome Pool | `0x4C2A0b915279f0C22EA766D58F9B815Ded2d2A3F` |

## Links

- [x402 Protocol](https://www.x402.org/) — HTTP 402 Payment Required standard
- [Coinbase Agentic Wallets](https://docs.cdp.coinbase.com/agentkit/docs/welcome)
- [RustChain](https://rustchain.org) — Proof-of-Antiquity blockchain
- [BoTTube](https://bottube.ai) — AI video platform using openclaw-x402
- [Aerodrome DEX](https://aerodrome.finance) — Swap USDC to wRTC

## License

MIT
