x402-solana
FastAPI middleware for the Coinbase x402 HTTP payment protocol on Base USDC.
Novel cross-chain primitive: bridges Solana wallet authentication with Coinbase x402 HTTP payments on Base — extracted from Sol Mate Trust API.
Install
pip install x402-solana
Usage
from fastapi import FastAPI, Depends
from x402_solana import require_x402_payment, X402Config, X402PaymentRequired, x402_exception_handler
app = FastAPI()
app.add_exception_handler(X402PaymentRequired, x402_exception_handler)
config = X402Config(
pay_to="0xYourBaseWalletAddress",
amount_usdc=0.5, # $0.50 USDC per request
description="DM unlock",
enabled=True, # Set False to bypass in dev
)
@app.post("/dm/send", dependencies=[Depends(require_x402_payment(config))])
async def send_dm(body: dict):
return {"status": "sent"}
Flow
Client → POST /dm/send (no X-Payment header)
Server → 402 Payment Required + {x402Version, accepts: [{network, asset, amount, payTo}]}
Client → pays 0.5 USDC on Base via Coinbase facilitator
Client → POST /dm/send (X-Payment: <proof>)
Server → verifies proof via https://x402.org/facilitator/verify
Server → 200 OK (request processed)
Configuration
| Field | Default | Description |
|---|---|---|
pay_to |
required | Base wallet address to receive USDC |
amount_usdc |
0.5 |
Payment amount in USDC |
network |
"base" |
"base" or "base-sepolia" |
asset |
USDC Base contract | ERC-20 token address |
description |
"API payment" |
Shown in wallet UI |
max_timeout_seconds |
300 |
Payment validity window |
enabled |
True |
Set False to bypass (dev/test) |
Graceful Degradation
If the Coinbase facilitator is unreachable, requests are allowed through automatically. Set enabled=False for local development.
License
MIT — extracted from Sol Mate Trust API. Built for EasyA × Consensus Miami 2026.
Metadata
Release files for solmate-x402 0.1.0
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 | |
|---|---|---|---|---|
| solmate_x402-0.1.0.tar.gz | 4.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| solmate_x402-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / solmate_x402-0.1.0.tar.gz
| Download URL | solmate_x402-0.1.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1b69c6062fae89409fd5bba7ccb53504c60c3bba3e05f2811fc516173cbdea5
|
|
BLAKE2b-256 checksum How to use checksums |
cbdd2a077935ba3f12a322108c64843a0d0af5daa02f94d62b621d22cc8f3a8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / solmate_x402-0.1.0-py3-none-any.whl
| Download URL | solmate_x402-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13474d933f2bf9719249bc1841aca0b2d555cea03f37b2983affa8d502f56711
|
|
BLAKE2b-256 checksum How to use checksums |
c5ed047c0e13ea84dfc7be4c0c5e7daaeac0d01529b3ea2162815b7a6d8dd5bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for solmate-x402 0.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.