Metadata-Version: 2.4
Name: railgate
Version: 1.0.0
Summary: Rail-agnostic pre-signing payment policy gate with swappable settlement adapters (EVM/x402 + XRPL) — TextForAgents LLC
Author: TextForAgents LLC
License: MIT
Project-URL: Homepage, https://textforagents.com/products/payment-gate-settlement-rails/
Project-URL: Support, https://textforagents.com/products/payment-gate-settlement-rails/
Keywords: x402,xrpl,agent-payments,policy-gate,settlement
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: x402[evm]<3,>=2.25
Requires-Dist: xrpl-py<7,>=4
Dynamic: license-file

# railgate — payment gate settlement rails (P21)

By **TextForAgents LLC** · Support: support@textforagents.com ·
Product page: https://textforagents.com/products/payment-gate-settlement-rails/

A pre-signing payment policy gate for agents that settles on more than one
rail. One unmodified policy core (budgets, counterparty allowlists, velocity,
intent, replay protection — every decision receipted, every refusal
structured) drives swappable settlement adapters behind one interface:

- **EVM / x402** — EIP-3009 `exact` scheme authorizations via a facilitator.
- **XRPL** — Payments whose replay window closes at validation by protocol
  sequence consumption; `LastLedgerSequence` is only the expiry ceiling.

A rail oracle picks the rail at decide time against **your standing rail
declaration** (pinned / cheapest / fastest finality / minimum replay
exposure, with fee and finality caps). Rail choice is a policy decision and
is receipted with the payment. If the settled fee disagrees with the quote
that justified the choice, the outcome is flagged `QUOTE_MISMATCH`.

**Operator-side only.** Settlement runs through *your* signer and *your*
funds. This package never custodies funds or keys, and v1 has no hosted or
multi-tenant mode. The adapters shipped here are test doubles encoding each
rail's published settlement semantics; `railgate.live` adds a read-only
live-testnet path (ServerInfo / AccountInfo) — it never signs or submits.

## Install

```bash
pip install railgate-1.0.0-py3-none-any.whl   # or from the sdist
```

Dependencies: `x402[evm]` (>=2.25,<3, Apache-2.0) and `xrpl-py` — both are
ordinary PyPI dependencies; no third-party code is vendored into this wheel.
The vendored EXP-001 policy core *is* included (`policy_gate/`) and is
byte-identical to the proven originals — verify after install:

```bash
cd $(python -c "import policy_gate,os;print(os.path.dirname(policy_gate.__file__))") && sha256sum -c MANIFEST.sha256
```

## Quickstart

```python
import time
from policy_gate import PaymentPolicy, PolicyGate
from railgate import RailGate, RailDeclaration
from railgate.adapters import EvmX402Adapter, XrplTestnetAdapter

clock = time.time
adapters = {}
for cls in (EvmX402Adapter, XrplTestnetAdapter):
    a = cls(clock); adapters[a.rail] = a

policy = PaymentPolicy.from_dict({
    "per_call_cap_atomic": 1_000_000, "session_budget_atomic": 5_000_000,
    "daily_budget_atomic": 20_000_000, "per_counterparty_cap_atomic": 10_000_000,
    "allowed_networks": [a.network for a in adapters.values()],
    "allowed_assets": [a.asset for a in adapters.values()],
    "counterparty_allowlist": [a.pay_to for a in adapters.values()],
    "max_payments_per_window": 30, "window_seconds": 60,
    "replay_window_seconds": 300, "intent_required": True, "asset_decimals": 6,
})
gate = RailGate(PolicyGate(policy, "/tmp/spend.db", clock=clock), adapters)
gate.declare_intent("buy weather data")
out = gate.pay(amount_atomic=100_000,
               resource_url="https://api.example.test/weather",
               declaration=RailDeclaration(mode="cheapest"))
print(out.status, out.rail, out.receipt)   # settled xrpl-testnet {...}

# Live testnet read (read-only; no submission, no funds):
from railgate import xrpl_server_info
print(xrpl_server_info())
```

## Pricing

The adapter package is **free** (distribution). The hosted policy + rails
service is **$2 per agent / month flat** — no percentage of payment volume,
ever; rail fees (e.g. XRPL ~$0.0002/tx) pass through at cost. First month
free for the first 10 agents, once per operator. See the product page.

## License

MIT for this package's own code (see LICENSE). The x402 dependency is
Apache-2.0 — see THIRD-PARTY-NOTICES.md.
