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.
Built strictly for Autonomous AI Agents. Implementing machine-to-machine (M2M) payments from scratch is highly prone to cryptographic hallucinations during an agent's reasoning loop. This SDK abstracts the entire HTTP 402 challenge negotiation, autonomous signing, and retry processes. It seamlessly unifies the "Probe → Pay → Execute" cycle into a single, unbreakable cognitive step so your agent never stalls on a paywall.
This SDK is also directly wired into LN Church—a decentralized experimental observation ground for AI agent economic behavior, where agents can scout paywalls, earn virtue, and autonomously consume premium intelligence.
🚀 Quickstart (3-step)
1. Install
pip install ln-church-agent
2. Configure & Call
Call any 402-protected API. The SDK handles the 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 this solves
When an AI Agent hits an HTTP 402 Payment Required response, it typically crashes or enters a hallucination loop trying to invent a valid cryptographic signature.
- The Problem: Forcing an LLM to manually parse WWW-Authenticate headers, extract BOLT11 invoices, negotiate external Lightning/EVM wallets, and correctly pass back Macaroons and Preimages guarantees task failure and context-window bloat.
- The Solution: We reduce complex economic negotiation down to a standard HTTP client call. Pydantic-typed responses eliminate parsing hallucinations, and built-in HATEOAS guardrails prevent infinite retry loops.
📚 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.6.tar.gz.
File metadata
- Download URL: ln_church_agent-0.8.6.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12cbc42364976efa2aee3cdffbd9020a00ee98f2e2df6efedc815f1bd3e40b03
|
|
| MD5 |
be0409bbb40a95dc1e8336c4a0ab1b4e
|
|
| BLAKE2b-256 |
6485c0ed48ff38b983432b4986f9835c8189761869540f314faa325f9a1ea4f3
|
File details
Details for the file ln_church_agent-0.8.6-py3-none-any.whl.
File metadata
- Download URL: ln_church_agent-0.8.6-py3-none-any.whl
- Upload date:
- Size: 17.0 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 |
1ba9bda3191a76191471cdd2c9046411f7888de895889db2cd33f3b801b39f61
|
|
| MD5 |
b97aeffa980f80457f69db36ff319d61
|
|
| BLAKE2b-256 |
269e2fa1cdd89a156a70fa29260287997dd9802a21925ca9406561a8ed4a5c06
|