Metadata-Version: 2.5
Name: apay
Version: 0.1.8
Summary: Universal HTTP 402 Micropayment Protocol & CLI for Autonomous AI Agents
Project-URL: Homepage, https://apay-network.vercel.app
Project-URL: Documentation, https://apay-network.vercel.app
Project-URL: Repository, https://github.com/a-pay/apay
Author-email: A-Pay Protocol Core Swarm <core@apay.network>
License: MIT
Keywords: ai-agents,autonomous-agents,base-l2,http-402,m2m-economy,micropayments,paywall,usdc
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: click>=8.1.0
Requires-Dist: eth-abi>=5.0.0
Requires-Dist: eth-account>=0.11.0
Requires-Dist: eth-hash>=0.7.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Requires-Dist: starlette>=0.38.0
Requires-Dist: uvicorn>=0.30.0
Provides-Extra: redis
Requires-Dist: redis>=5.0.0; extra == 'redis'
Description-Content-Type: text/markdown

# ⚡ A-Pay Protocol (AgentPay)
> **The Universal Micropayment & Economic Layer for Autonomous AI Agents**

<!-- mcp-name: io.github.neuralaisofficial-lang/apay -->

[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)
[![Status](https://img.shields.io/badge/status-active_core-success.svg)]()
[![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)]()
[![Live Console](https://img.shields.io/badge/Console-Live_on_Vercel-success.svg)](https://apay-network.vercel.app)

---

## 🌐 Live Production Network & On-Chain Addresses
* **Live Web App & Console**: [https://apay-network.vercel.app](https://apay-network.vercel.app)
* **Base Mainnet (Chain ID `8453`)**:
  * **$APAY Token (ERC-20)**: [`0x8dd4ff9035c7d4e0bef30aa64fc30d128a4066c3`](https://basescan.org/token/0x8dd4ff9035c7d4e0bef30aa64fc30d128a4066c3) (100M Cap, Base L2)
  * **Aerodrome Live Pool**: [`vAMM-WETH/APAY` (0x6933...7777)](https://aerodrome.finance/swap?from=eth&to=0x8dd4ff9035c7d4e0bef30aa64fc30d128a4066c3)
  * **DexScreener Chart**: [Live APAY/WETH Chart](https://dexscreener.com/base/0x6933dd2B7D72d8561005E475AFa147E47A3c7777)
* **Base Sepolia L2 (Chain ID `84532`)**:
  * **APayRouter (V1 Gateway)**: [`0x71434344beEF9C44fF3BC95572bEB7bFB8847ec6`](https://sepolia.basescan.org/address/0x71434344beEF9C44fF3BC95572bEB7bFB8847ec6) (1.0% Protocol Fee)
  * **APayRouterV2 (Enterprise Router)**: [`0xD08c8A337E5339d1c083E06d74A9265956ceEA16`](https://sepolia.basescan.org/address/0xD08c8A337E5339d1c083E06d74A9265956ceEA16) (Cumulative Channels & Merkle Claims)
  * **EscrowVault (Session Keys)**: [`0x3E35a9E802627a3D9A86D6554e72b1C446E34aAF`](https://sepolia.basescan.org/address/0x3E35a9E802627a3D9A86D6554e72b1C446E34aAF) (Sub-Agent Delegated Spending)
  * **StakingVault (Anti-Spam Collateral)**: [`0xD2f3F4D97f4a3fdC9d4eEDfB9747BF9D80CF6225`](https://sepolia.basescan.org/address/0xD2f3F4D97f4a3fdC9d4eEDfB9747BF9D80CF6225) (Anti-Spam Staking & Slashing Engine)


---

## 🎯 Vision & Identity
**A-Pay** is an ultra-lightweight, zero-latency, open economic rail designed for the machine-to-machine (M2M) economy. Just as UPI revolutionized human digital payments in India, A-Pay enables autonomous AI software agents to discover, consume, and pay for data, compute, APIs, and micro-services on the fly—without credit cards, human KYC, or seed phrase friction.

---

## 🚀 1-Command Experience

### 1. Website / API Owners (The Sellers)
Scaffold a fullstack monetized AI Agent app (Next.js, FastAPI, or Express) in 60 seconds:
```bash
npx create-apay-app my-paid-agent
```

Or protect ANY existing website or API with an instant HTTP 402 crypto paywall proxy—**zero code modifications required**:
```bash
apay protect --target http://localhost:8000 --price 0.001 --wallet 0xYourWalletAddress
```
* Incoming requests from AI bots will automatically receive an **HTTP 402 Payment Required** challenge.
* Once the AI agent's cryptographic micropayment is verified (<15ms), the request is forwarded to your server and data is unlocked!

---

### 2. AI Agent Developers (The Buyers)
Give your AI agent an in-memory wallet and strict spending guardrails with **2 lines of code**:
```python
from apay import APaySession, AgentWallet

# Generate or load wallet with daily safety limit
wallet = AgentWallet(private_key="0x...", max_per_call_usdc=0.01, daily_budget_usdc=5.0)
session = APaySession(wallet)

# Automatically handles HTTP 402 challenges & settles on the fly
response = session.get("https://protected-api.com/market-data")
print(response.json())
```

---

### 3. Claude Desktop & Cursor (Model Context Protocol / MCP)
Equip Claude Desktop, Cursor, Antigravity, or Cline with an autonomous A-Pay micro-wallet in 1 click via **Smithery.ai**:
```bash
npx -y @smithery/cli install apay --client claude
```

Or add directly to `claude_desktop_config.json` or `.cursor/mcp.json` (zero-setup via `uvx`):
```json
{
  "mcpServers": {
    "apay": {
      "command": "uvx",
      "args": ["apay", "mcp"],
      "env": {
        "APAY_NETWORK": "base-mainnet",
        "APAY_CURRENCY": "DUAL",
        "APAY_MAX_PER_CALL": "0.05",
        "APAY_DAILY_BUDGET": "2.0"
      }
    }
  }
}
```
Now your assistant can autonomously inspect balances, probe paywalls, and settle HTTP 402 micropayments on Base L2!

---

## 📦 Directory Structure

```text
apay/
├── src/
│   └── apay/
│       ├── __init__.py      # Package exports
│       ├── cli.py           # ⚡ 1-Command CLI (`apay protect`, `apay wallet new`, `apay pay`)
│       ├── client.py        # 🤖 Auto-settling HTTP client (sync & async)
│       ├── wallet.py        # 🔐 In-memory wallet + local spending limits
│       ├── proxy.py         # 🛡️ Ultra-light reverse proxy paywall (Starlette + EIP-712)
│       ├── relayer.py       # 📊 Settlement journal & batch relayer
│       └── integrations/    # 🔗 LangChain & CrewAI agent wrappers
├── contracts/               # Base Sepolia Smart Contracts (APAYToken & APayRouter)
├── tests/                   # Automated integration & security test suite
├── spec/                    # RFC wire format & security model specifications
└── pyproject.toml           # Hatchling packaging configuration
```

---

## 🛠️ Installation & Quickstart

```bash
# 1. Install A-Pay via pip
pip install apay

# 2. Generate a new Agent Wallet with spending limits
apay wallet new

# 3. Protect any website or API with an instant HTTP 402 Paywall
apay protect --target http://localhost:8000 --price 0.001 --wallet 0xYourPayoutWalletAddress
```

---
*A-Pay is an open-source decentralized economic protocol for autonomous machine agents. Built on Base L2.*
