4mica-x402
Python integration for the x402 Payment Protocol with 4mica credit flow support.
Install
pip install 4mica-x402
Optional extras:
fastapi(FastAPI middleware)flask(Flask middleware)httpx(async HTTP client wrapper)requests(sync HTTP client wrapper)all(everything)
Quick Start (Server)
from fastapi import FastAPI
from fourmica_x402.http import fastapi_payment_middleware_from_config
app = FastAPI()
routes = {
"GET /premium": {
"accepts": {
"scheme": "4mica-credit",
"price": "$0.01",
"network": "eip155:11155111",
"payTo": "0xRecipient",
}
}
}
middleware = fastapi_payment_middleware_from_config(
routes,
tab_endpoint="https://api.example.com/payment/tab",
)
@app.middleware("http")
async def x402_mw(request, call_next):
return await middleware(request, call_next)
Quick Start (Client)
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from fourmica_x402.client_scheme import FourMicaEvmScheme
client = x402ClientSync()
client.register("eip155:11155111", FourMicaEvmScheme("0xYourPrivateKey"))
session = x402_requests(client)
resp = session.get("https://api.example.com/premium")
print(resp.status_code, resp.text)
Development
python -m build
python -m pytest
Install dev tools:
pip install -e .[dev]
Metadata
Release files for 4mica-x402 1.2.3
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 | |
|---|---|---|---|---|
| 4mica_x402-1.2.3.tar.gz | 12.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 4mica_x402-1.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.8 kB
Release files / 4mica_x402-1.2.3.tar.gz
| Download URL | 4mica_x402-1.2.3.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d2647a25ba8c3946aa7a964fee1c802100cf492f4086d00e28560b04d1ca04e
|
|
BLAKE2b-256 checksum How to use checksums |
8509a3ec4f59c61a54bbe03b79e0f8b954d0708e1e9248231a473d2ba43ee7c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / 4mica_x402-1.2.3-py3-none-any.whl
| Download URL | 4mica_x402-1.2.3-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a66ec5de28dc0450e2c8783ebb36bf187b34ea130aff5303c438b97264446cba
|
|
BLAKE2b-256 checksum How to use checksums |
fa5e39496c41dbeb1f464942b2ce394057094b82dd6fefebb31cd68f3fb08194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for 4mica-x402 1.2.3
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.