Clearinghouse SDK for agent-to-agent payments.
Project description
rescontre
Python SDK for Rescontre, a clearinghouse for agent-to-agent payments. Agents and resource servers record commitments against a bilateral ledger and settle in periodic batches instead of on every request.
Why?
Instead of settling every API call on-chain, Rescontre nets obligations and settles the differences. Up to ~90% fewer settlement transactions.
Install
pip install rescontre
Quickstart
The SDK requires an API key for verify and settle calls. Mint one on the facilitator with POST /admin/keys (operator-only, requires X-Internal-Secret), then either set RESCONTRE_API_KEY in your environment or pass api_key= to the client:
export RESCONTRE_API_KEY=<64-char hex key>
from rescontre import Client, Direction
# Picks up RESCONTRE_API_KEY from the environment...
with Client("http://localhost:3000") as c:
...
# ...or pass it explicitly:
with Client("http://localhost:3000", api_key="<64-char hex key>") as c:
c.register_agent("agent-1", wallet_address="0xAAA...")
c.register_server("server-1", wallet_address="0xBBB...", endpoints=["/api/data"])
c.create_agreement("agent-1", "server-1", credit_limit=10_000_000, settlement_frequency=100)
check = c.verify("agent-1", "server-1", amount=1_000_000, nonce="n-1")
assert check.valid, check.reason
receipt = c.settle(
"agent-1", "server-1",
amount=1_000_000, nonce="n-1",
description="GET /api/data",
direction=Direction.AgentToServer,
)
print(receipt.commitment_id, receipt.net_position)
Amounts are integers in microdollars ($1 == 1_000_000).
Connect
# Local development
with Client("http://localhost:3000") as c:
# Production
with Client("https://rescontre-production.up.railway.app") as c:
# After multiple settle calls in both directions...
result = c.bilateral_settlement("agent-1", "server-1")
print(f"Gross: ${result.gross_volume / 1_000_000:.2f}")
print(f"Net: ${result.net_amount / 1_000_000:.2f}")
print(f"Compression: {result.compression:.0%}")
Examples
End-to-end demo of the x402 → verify → settle → net flow lives in examples/. The example server uses FastAPI, which is not a dependency of the SDK itself. Install it separately:
pip install fastapi uvicorn
# Terminal 1
python examples/demo_server.py
# Terminal 2
python examples/demo_client.py
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 rescontre-0.1.1.tar.gz.
File metadata
- Download URL: rescontre-0.1.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0e8391cdd161332f10cd4d0a7ca42a94fad8a9034bcab2a0890fbe189576614
|
|
| MD5 |
06ad70edd2b2892a7a2f5ab50617af4f
|
|
| BLAKE2b-256 |
0814e825105b1f339740866184d612b76d4deb3ef522a36a8dfcdd95e825dd19
|
File details
Details for the file rescontre-0.1.1-py3-none-any.whl.
File metadata
- Download URL: rescontre-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa64faee935049d87d2361449a73314259e0fdc87d5fb48b0387526af33eafb3
|
|
| MD5 |
1270a50835af6ec1fc33fc4b17aa9e93
|
|
| BLAKE2b-256 |
867769b973bc41d8cac2eb45cc8f386d0b1f91d6e4071d4fc4605453f03e6494
|