ASGI middleware for XRPL-backed x402 API payments
Project description
xrpl-x402-middleware
xrpl-x402-middleware protects ASGI and FastAPI routes with exact XRPL x402 payments.
Install
pip install xrpl-x402-middleware
Optional Coinbase Python x402 interop:
pip install "xrpl-x402-middleware[x402]"
Quick Start
from fastapi import FastAPI, Request
from xrpl_x402_middleware import PaymentMiddlewareASGI, require_payment
app = FastAPI()
app.add_middleware(
PaymentMiddlewareASGI,
route_configs={
"GET /premium": require_payment(
facilitator_url="http://127.0.0.1:8000",
bearer_token="replace-with-your-token",
pay_to="rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe",
network="xrpl:1",
xrp_drops=1000,
description="One premium request",
)
},
)
@app.get("/premium")
async def premium(request: Request) -> dict[str, str]:
payment = request.state.x402_payment
return {"payer": payment.payer, "tx_hash": payment.tx_hash}
Public API
PaymentMiddlewareASGIrequire_payment(...)XRPLFacilitatorClient- Optional adapters under
xrpl_x402_middleware.adapters.x402
Compatibility
- Python
3.12 - Depends on
xrpl-x402-core - Optional adapter extra pins
x402==2.3.0 - Examples target
xrpl:1; mainnet usage usesxrpl:0
Provenance
The implementation is independently developed for the open x402 protocol and does not copy x402-xrpl.
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 xrpl_x402_middleware-0.1.0.tar.gz.
File metadata
- Download URL: xrpl_x402_middleware-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a81256497f2206cd41b007769cd1af54b22c86adcb005f5c91ca7af25c08e4d
|
|
| MD5 |
8f3f0fcdb4aadb564537cc53f33835fb
|
|
| BLAKE2b-256 |
9a4fbe97db0b51c8e1e56028fd3603f5df5d51a471e84083d3f8457cc76c2d63
|
Provenance
The following attestation bundles were made for xrpl_x402_middleware-0.1.0.tar.gz:
Publisher:
publish-package.yml on lgcarrier/xrpl-x402-stack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xrpl_x402_middleware-0.1.0.tar.gz -
Subject digest:
4a81256497f2206cd41b007769cd1af54b22c86adcb005f5c91ca7af25c08e4d - Sigstore transparency entry: 1107651309
- Sigstore integration time:
-
Permalink:
lgcarrier/xrpl-x402-stack@02af097aeade32de5f932881c6b28aa1e045f733 -
Branch / Tag:
refs/tags/middleware-v0.1.0 - Owner: https://github.com/lgcarrier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@02af097aeade32de5f932881c6b28aa1e045f733 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xrpl_x402_middleware-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xrpl_x402_middleware-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ddd8a19e70a030f1cbdb6532b2c8e65e3a71542b04a3b6e3160a7e14a9d5db
|
|
| MD5 |
ed9a4b36bdf4124f28dc88feaadade3b
|
|
| BLAKE2b-256 |
46a99df022cf3392c45cd903a9a625a5b4fc95e4d70096933f7c8fb6498164d8
|
Provenance
The following attestation bundles were made for xrpl_x402_middleware-0.1.0-py3-none-any.whl:
Publisher:
publish-package.yml on lgcarrier/xrpl-x402-stack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xrpl_x402_middleware-0.1.0-py3-none-any.whl -
Subject digest:
20ddd8a19e70a030f1cbdb6532b2c8e65e3a71542b04a3b6e3160a7e14a9d5db - Sigstore transparency entry: 1107651315
- Sigstore integration time:
-
Permalink:
lgcarrier/xrpl-x402-stack@02af097aeade32de5f932881c6b28aa1e045f733 -
Branch / Tag:
refs/tags/middleware-v0.1.0 - Owner: https://github.com/lgcarrier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@02af097aeade32de5f932881c6b28aa1e045f733 -
Trigger Event:
push
-
Statement type: