A Python reference client for HTTP 402 settlement across x402, L402, MPP, and fallback flows.
Project description
ln-church-agent
Python SDK for calling L402 / HTTP 402 pay-per-use APIs with automatic payment and retry.
Quickstart (3-step)
1. Install
pip install ln-church-agent
2. Configure & Call
Call any 402-protected API. The SDK handles the 402 challenge, payment, and retry under the hood.
from ln_church_agent import Payment402Client
client = Payment402Client(
base_url="https://your-402-api.com",
)
# Detects 402 -> Pays invoice -> Retries -> Returns JSON
result = client.execute_request(
method="POST",
endpoint="/api/protected",
payload={"input": "hello"}
)
print(result)
What happens under the hood?
This SDK abstracts the "Payment-Retry Loop" so your agent doesn't have to:
- Detects
402 Payment Required. - Negotiates the challenge (L402, MPP, or x402 support).
- Pays the invoice via your configured Lightning or EVM provider.
- Retries the request automatically and returns the final JSON response.
Why use this SDK?
- No manual invoice handling: Automates macaroon extraction and preimage submission.
- No retry logic needed: Built-in loops and HATEOAS navigation guardrails.
- Built for Agents: Strongly typed Pydantic responses eliminate "cryptographic hallucinations" during the reasoning loop.
Detailed Documentation
Explore the full capabilities of the agentic economic loop:
- Quickstart & Authentication: Identity, keys, and generic client configuration.
- Architecture & Capabilities: Deep dive into x402, L402, and HATEOAS logic.
- The LN Church Pilgrimage: Using the reference adapter for Oracle and Ritual tasks.
- Lightning Providers: Configuration for Alby and LNBits.
- Integrations: Setting up MCP (Model Context Protocol) and LangChain.
- Monzen Observation Network: Scouting L402 paywalls and Decentralized DNS.
License
MIT
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 ln_church_agent-0.8.5.tar.gz.
File metadata
- Download URL: ln_church_agent-0.8.5.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fea64c90d830c50295792f309401ff6c003167225a0ff90f9ea763f0b38c5c7c
|
|
| MD5 |
d73157a524ed293c96f5749a26efb14b
|
|
| BLAKE2b-256 |
7ad777dc6132d026964933bd428c8edb5a0948b6ab5137760ffbeb8e7be99463
|
File details
Details for the file ln_church_agent-0.8.5-py3-none-any.whl.
File metadata
- Download URL: ln_church_agent-0.8.5-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a8682ee3bd5219fa5ce3f4383cdb0d9616bfea66165e936436e13c7df20c429
|
|
| MD5 |
afccc247b57a61e149285de8fd9a9e43
|
|
| BLAKE2b-256 |
a4e2c7ec48ece9a7a6591d089977bc90173edc4b5ccd900773b819509a2ab949
|