Skip to main content

xrpl-x402-middleware

Canonical x402 v2 HTTP and MCP resource-server integration for XRPL.

from xrpl_x402_middleware import PaymentMiddlewareASGI, require_payment

app.add_middleware(
    PaymentMiddlewareASGI,
    routes={
        "GET /premium": require_payment(
            pay_to="rMerchant",
            network="xrpl:1",
            xrp_drops=1000,
            resource="https://merchant.example/premium",
            description="Premium data",
            service_name="Example merchant",
            tags=["premium", "xrpl"],
        )
    },
    facilitator_url="http://127.0.0.1:8000",
    bearer_token="replace-with-your-token",
)

The middleware verifies first, buffers the successful handler response, settles, and only then releases protected bytes. Handler errors are not settled. For a settlement_pending result, the upstream x402 resource server retries the identical settlement envelope exactly once. If it is still pending, a later identical request resumes settlement from the cached protected response without rerunning the handler or exposing protected bytes early.

Unsafe methods require the payment-identifier extension. Configure RedisResourceResponseStore so a matching retry can recover the handler result without repeating side effects. The store preserves exact response bytes and retains them for at least maxTimeoutSeconds plus a safety margin (with a 600-second minimum by default), so a still-valid retry cannot repeat the handler after cache expiry.

Before facilitator verification, the middleware rejects payload resource metadata that does not match the authoritative HTTP route or MCP tool. Recovery fingerprints also include the HTTP method, effective URL and query, and a digest of the exact request body; MCP fingerprints include the exact tool name and a digest of its canonical arguments. Raw request bodies and tool arguments are not persisted in the binding record.

Use create_xrpl_mcp_payment_wrapper for paid MCP tools. It composes the official x402 MCP wrapper, registers XRPL exact, preserves extension data, and requires payment identifiers plus RedisResourceResponseStore for non-idempotent tools. Install the helper with pip install "xrpl-x402-middleware[mcp]".

Metadata

Release files for xrpl-x402-middleware 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xrpl-x402-middleware 0.2.0
File Size Uploaded Provenance Actions
xrpl_x402_middleware-0.2.0.tar.gz 13.7 kB With provenance Details for xrpl_x402_middleware-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xrpl-x402-middleware 0.2.0
File Interpreter ABI Platform Actions
xrpl_x402_middleware-0.2.0-py3-none-any.whl Python 3 none any Details for xrpl_x402_middleware-0.2.0-py3-none-any.whl

Total release size: 31.1 kB

Release files / xrpl_x402_middleware-0.2.0.tar.gz

Download URL xrpl_x402_middleware-0.2.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
243bb4f628ec61dba171b42bab4e8ef381c40a438a46490d013783c070d79dd2
BLAKE2b-256 checksum
How to use checksums
b88c6ae9a286341e32d8c6e2212cc55367288605c10b127b7bdbd1b8b10f8dcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / xrpl_x402_middleware-0.2.0-py3-none-any.whl

Download URL xrpl_x402_middleware-0.2.0-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7b38baaff5f00446a1d50c9b256bb61e5c338343892c0ec686b222dbc235a45
BLAKE2b-256 checksum
How to use checksums
aec8ed786ad1e6c1b6fd0b75a20d1285aee510b5ac8b5e6827b42089fa2fcbd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Security for xrpl-x402-middleware 0.2.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xrpl_x402_middleware-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page