agentpay-x402 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentpay_x402-0.1.0/LICENSE +17 -0
- agentpay_x402-0.1.0/PKG-INFO +397 -0
- agentpay_x402-0.1.0/README.md +352 -0
- agentpay_x402-0.1.0/agentpay/__init__.py +50 -0
- agentpay_x402-0.1.0/agentpay/_wallet.py +356 -0
- agentpay_x402-0.1.0/agentpay/client.py +67 -0
- agentpay_x402-0.1.0/agentpay/routines/__init__.py +1 -0
- agentpay_x402-0.1.0/agentpay_x402.egg-info/PKG-INFO +397 -0
- agentpay_x402-0.1.0/agentpay_x402.egg-info/SOURCES.txt +12 -0
- agentpay_x402-0.1.0/agentpay_x402.egg-info/dependency_links.txt +1 -0
- agentpay_x402-0.1.0/agentpay_x402.egg-info/requires.txt +6 -0
- agentpay_x402-0.1.0/agentpay_x402.egg-info/top_level.txt +1 -0
- agentpay_x402-0.1.0/pyproject.toml +41 -0
- agentpay_x402-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 romudille
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentpay-x402
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pay-per-call crypto data for AI agents — x402 + USDC on Stellar or Base
|
|
5
|
+
Author-email: romudille <velvetvau@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 romudille
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
23
|
+
|
|
24
|
+
Project-URL: Homepage, https://github.com/romudille-bit/agentpay
|
|
25
|
+
Project-URL: Repository, https://github.com/romudille-bit/agentpay
|
|
26
|
+
Project-URL: Issues, https://github.com/romudille-bit/agentpay/issues
|
|
27
|
+
Keywords: x402,stellar,ai-agents,crypto,micropayments,mcp
|
|
28
|
+
Classifier: Development Status :: 4 - Beta
|
|
29
|
+
Classifier: Intended Audience :: Developers
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
36
|
+
Requires-Python: >=3.10
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: stellar-sdk>=10.0.0
|
|
40
|
+
Requires-Dist: httpx>=0.27.0
|
|
41
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
42
|
+
Provides-Extra: routines
|
|
43
|
+
Requires-Dist: agentpay-x402; extra == "routines"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# AgentPay — Ditch those API keys.
|
|
47
|
+
|
|
48
|
+
Pay per call. No subscriptions. No human in the loop.
|
|
49
|
+
|
|
50
|
+
AgentPay is an x402 payment gateway for AI agents. Access 14 crypto data tools using USDC on Stellar or Base — agents discover, pay, and get data back autonomously, within a hard budget cap.
|
|
51
|
+
|
|
52
|
+
→ **14 live tools**: token prices, open interest, orderbook depth, whale activity, funding rates, gas tracker, DeFi TVL, Fear & Greed, yield scanner, token security, Dune queries and more
|
|
53
|
+
→ **Budget-aware Session**: agents estimate costs, track spend, never exceed budget
|
|
54
|
+
→ **x402 protocol**: works with any x402-compatible agent
|
|
55
|
+
→ **Stellar + Base**: pay with USDC on either network — Stellar (5s, ~$0.00001 fee) or Base mainnet (2s, ~$0.0001 fee)
|
|
56
|
+
|
|
57
|
+
**Live gateway (mainnet)**: `https://gateway-production-2cc2.up.railway.app`
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Quickstart — 3 steps
|
|
62
|
+
|
|
63
|
+
### Step 1: Get a wallet with USDC
|
|
64
|
+
|
|
65
|
+
**Option A — Stellar mainnet (recommended)**
|
|
66
|
+
|
|
67
|
+
Send USDC to a Stellar wallet via [Coinbase](https://coinbase.com), [Lobstr](https://lobstr.co), or any Stellar DEX. Then use your Stellar secret key (`S...`) directly.
|
|
68
|
+
|
|
69
|
+
USDC issuer on Stellar mainnet: `GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN`
|
|
70
|
+
Gateway: `https://gateway-production-2cc2.up.railway.app` — use `network="mainnet"`
|
|
71
|
+
|
|
72
|
+
**Option B — Base mainnet (alternative)**
|
|
73
|
+
|
|
74
|
+
Send USDC to an EVM wallet on Base. Use your EVM private key with `network="base"`.
|
|
75
|
+
|
|
76
|
+
USDC contract on Base: `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
|
|
77
|
+
Gateway: `https://gateway-production-2cc2.up.railway.app` — use `network="base"`
|
|
78
|
+
|
|
79
|
+
**Option C — Testnet (free, no wallet needed)**
|
|
80
|
+
|
|
81
|
+
One command gives you a Stellar testnet wallet pre-loaded with 5 USDC:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
curl https://gateway-testnet-production.up.railway.app/faucet
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use `network="testnet"` and `gateway_url="https://gateway-testnet-production.up.railway.app"` in your Session.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Step 2: Create a Session with a budget
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from agent.wallet import AgentWallet, Session, BudgetExceeded
|
|
95
|
+
|
|
96
|
+
# Option A — Stellar mainnet
|
|
97
|
+
wallet = AgentWallet(secret_key="S...", network="mainnet")
|
|
98
|
+
GATEWAY = "https://gateway-production-2cc2.up.railway.app"
|
|
99
|
+
|
|
100
|
+
# Option C — Testnet (faucet wallet)
|
|
101
|
+
# wallet = AgentWallet(secret_key="S...", network="testnet")
|
|
102
|
+
# GATEWAY = "https://gateway-testnet-production.up.railway.app"
|
|
103
|
+
|
|
104
|
+
with Session(wallet=wallet, gateway_url=GATEWAY, max_spend="0.05") as session:
|
|
105
|
+
print(f"Balance: {wallet.get_usdc_balance()} USDC")
|
|
106
|
+
print(f"Budget: {session.remaining()} remaining")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `Session` enforces a hard USDC cap across all calls. It raises `BudgetExceeded` before any payment goes out if a tool would push you over, and automatically falls back to the next-cheapest tool in the same category when the preferred one is too expensive.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### Step 3: Call tools — payment is automatic
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
with Session(wallet=wallet, gateway_url=GATEWAY, max_spend="0.05") as session:
|
|
117
|
+
|
|
118
|
+
# Token price — $0.001
|
|
119
|
+
r = session.call("token_price", {"symbol": "ETH"})
|
|
120
|
+
print(f"ETH: ${r['price_usd']:,.2f} ({r['change_24h_pct']:+.2f}% 24h)")
|
|
121
|
+
|
|
122
|
+
# Open interest — $0.002
|
|
123
|
+
r = session.call("open_interest", {"symbol": "ETH"})
|
|
124
|
+
print(f"ETH OI: ${r['total_oi_usd']/1e9:.2f}B ({r['oi_change_24h_pct']:+.2f}% 24h)")
|
|
125
|
+
|
|
126
|
+
# Orderbook depth — $0.002
|
|
127
|
+
r = session.call("orderbook_depth", {"symbol": "ETHUSDT"})
|
|
128
|
+
slip = next(d['slippage_pct'] for d in r['depth'] if d['notional_usd'] == 250_000)
|
|
129
|
+
print(f"ETH $250k slippage: {slip:.3f}%")
|
|
130
|
+
|
|
131
|
+
# Funding rates — $0.003
|
|
132
|
+
r = session.call("funding_rates", {"asset": "ETH"})
|
|
133
|
+
for ex in r.get("exchanges", [])[:2]:
|
|
134
|
+
print(f" {ex['exchange']}: {ex['funding_rate_pct']:+.4f}%/8h")
|
|
135
|
+
|
|
136
|
+
print(f"\nTotal spent: {session.spent()}")
|
|
137
|
+
print(f"Remaining: {session.remaining()}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Each `session.call()` handles the full x402 flow internally:
|
|
141
|
+
|
|
142
|
+
1. Checks your remaining budget against the tool's price (pre-flight, no payment yet)
|
|
143
|
+
2. POSTs to the gateway, receives a `402` with `{payment_id, amount_usdc, pay_to}`
|
|
144
|
+
3. Sends USDC on Stellar — confirmed in ~3–5 seconds
|
|
145
|
+
4. Retries the request with `X-Payment: tx_hash=<hash>,from=<addr>,id=<payment_id>`
|
|
146
|
+
5. Returns the data
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Available Tools
|
|
151
|
+
|
|
152
|
+
| Tool | Price | Parameters | Returns |
|
|
153
|
+
|------|-------|-----------|---------|
|
|
154
|
+
| `token_price` | $0.001 | `symbol` (BTC, ETH, SOL…) | price_usd, change_24h_pct, market_cap_usd |
|
|
155
|
+
| `gas_tracker` | $0.001 | — | slow/standard/fast gwei, base_fee_gwei |
|
|
156
|
+
| `fear_greed_index` | $0.001 | `limit` (days of history, default 1) | value 0–100, value_classification, history[] |
|
|
157
|
+
| `token_market_data` | $0.001 | `token_a`, `token_b` | volume_24h_usd, market_cap_usd, price_usd |
|
|
158
|
+
| `wallet_balance` | $0.002 | `address`, `chain` (ethereum/stellar) | token balances |
|
|
159
|
+
| `whale_activity` | $0.002 | `token`, `min_usd` (default 100k) | large_transfers[] with exchange direction, total_volume_usd |
|
|
160
|
+
| `defi_tvl` | $0.002 | `protocol` (optional, e.g. "uniswap") | tvl, change_1d, change_7d, chains[] |
|
|
161
|
+
| `token_security` | $0.002 | `contract_address`, `chain` (ethereum/bsc) | risk_level, is_honeypot, buy_tax, sell_tax |
|
|
162
|
+
| `open_interest` | $0.002 | `symbol` (BTC, ETH…) | total_oi_usd, oi_change_1h_pct, oi_change_24h_pct, long_short_ratio, exchanges[] |
|
|
163
|
+
| `orderbook_depth` | $0.002 | `symbol` (e.g. ETHUSDT), `exchange` (binance/bybit) | best_bid, best_ask, spread_pct, slippage at $10k/$50k/$250k |
|
|
164
|
+
| `funding_rates` | $0.003 | `asset` (optional, e.g. "BTC") | funding_rate_pct, annualized_rate_pct, sentiment per exchange |
|
|
165
|
+
| `crypto_news` | $0.003 | `currencies` (e.g. "ETH,BTC"), `filter` (hot/new/rising) | headlines[] with title, url, sentiment, score |
|
|
166
|
+
| `yield_scanner` | $0.004 | `token`, `chain` (optional), `min_tvl` (default $1M) | top 10 pools by APY with protocol, tvl_usd, risk_level |
|
|
167
|
+
| `dune_query` | $0.005 | `query_id`, `limit` (default 25), `fast_only` (bool) | rows[], columns[], row_count from Dune Analytics |
|
|
168
|
+
|
|
169
|
+
Discover all tools dynamically:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
import httpx
|
|
173
|
+
tools = httpx.get(f"{GATEWAY}/tools").json()["tools"]
|
|
174
|
+
for t in tools:
|
|
175
|
+
print(f"{t['name']:<22} ${t['price_usdc']} — {t['description']}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## The derivatives demo
|
|
181
|
+
|
|
182
|
+
> "My bot read funding rates (+0.08%/8h on ETH), confirmed rising open interest (+12% in 24h), checked orderbook depth ($0.31% slippage on a $250k sell), and decided not to open the short. Total data cost: $0.007."
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
with Session(wallet=wallet, gateway_url=GATEWAY, max_spend="0.05") as session:
|
|
186
|
+
|
|
187
|
+
rates = session.call("funding_rates", {"asset": "ETH"})
|
|
188
|
+
oi = session.call("open_interest", {"symbol": "ETH"})
|
|
189
|
+
depth = session.call("orderbook_depth", {"symbol": "ETHUSDT"})
|
|
190
|
+
|
|
191
|
+
top_rate = max(rates["exchanges"], key=lambda x: x["funding_rate_pct"])
|
|
192
|
+
oi_24h = oi["oi_change_24h_pct"]
|
|
193
|
+
slip_250k = next(d["slippage_pct"] for d in depth["depth"] if d["notional_usd"] == 250_000)
|
|
194
|
+
|
|
195
|
+
print(f"Funding: {top_rate['funding_rate_pct']:+.4f}%/8h on {top_rate['exchange']}")
|
|
196
|
+
print(f"OI 24h: {oi_24h:+.2f}%")
|
|
197
|
+
print(f"Slippage: {slip_250k:.3f}% on a $250k sell")
|
|
198
|
+
print(f"Cost: {session.spent()}")
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Payment Options
|
|
204
|
+
|
|
205
|
+
AgentPay accepts USDC payments on two networks:
|
|
206
|
+
|
|
207
|
+
- **Stellar** — ~$0.00001 per tx, 5-second settlement (recommended for agents using the Python SDK)
|
|
208
|
+
- **Base** — ~$0.0001 per tx, 2-second settlement (EIP-3009 `transferWithAuthorization` on Base mainnet)
|
|
209
|
+
|
|
210
|
+
The gateway's `402` response advertises both options simultaneously. Clients pick the network that suits them — no configuration required on the tool side.
|
|
211
|
+
|
|
212
|
+
### Stellar Payment Verification
|
|
213
|
+
|
|
214
|
+
Stellar payments are verified on-chain via [Stellar Horizon](https://horizon.stellar.org). The gateway checks that the transaction exists, is confirmed, sends USDC to the gateway address, and the amount matches the quoted price — all without requiring agents to trust a third party.
|
|
215
|
+
|
|
216
|
+
Base payments use Mode B direct on-chain settlement: the client calls `transferWithAuthorization` on the USDC contract and sends the `tx_hash` in the `PAYMENT-SIGNATURE` header. The gateway verifies the receipt via JSON-RPC.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## MCP Server
|
|
221
|
+
|
|
222
|
+
AgentPay ships a Model Context Protocol server that gives Claude Desktop (and any MCP client) direct access to all 14 tools. Payments happen automatically in the background using Stellar USDC.
|
|
223
|
+
|
|
224
|
+
See **[README_MCP.md](README_MCP.md)** for setup instructions.
|
|
225
|
+
|
|
226
|
+
**Quick config** (`claude_desktop_config.json`):
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"mcpServers": {
|
|
230
|
+
"agentpay": {
|
|
231
|
+
"command": "python",
|
|
232
|
+
"args": ["/path/to/agentpay/gateway/mcp_server.py"],
|
|
233
|
+
"env": {
|
|
234
|
+
"STELLAR_SECRET_KEY": "S...",
|
|
235
|
+
"AGENTPAY_GATEWAY_URL": "https://gateway-production-2cc2.up.railway.app"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Or via npm:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npx @romudille/agentpay-mcp
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Without the SDK — raw HTTP
|
|
251
|
+
|
|
252
|
+
The x402 flow works with any HTTP client in any language.
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
GATEWAY="https://gateway-production-2cc2.up.railway.app"
|
|
256
|
+
AGENT_ADDR="G..." # your Stellar public key
|
|
257
|
+
|
|
258
|
+
# 1. Call the tool → receive 402 payment challenge
|
|
259
|
+
RESPONSE=$(curl -s -X POST "$GATEWAY/tools/token_price/call" \
|
|
260
|
+
-H "Content-Type: application/json" \
|
|
261
|
+
-d "{\"parameters\":{\"symbol\":\"ETH\"},\"agent_address\":\"$AGENT_ADDR\"}")
|
|
262
|
+
|
|
263
|
+
PAYMENT_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['payment_id'])")
|
|
264
|
+
AMOUNT=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['amount_usdc'])")
|
|
265
|
+
PAY_TO=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['pay_to'])")
|
|
266
|
+
|
|
267
|
+
# 2. Send USDC on Stellar (memo = payment_id)
|
|
268
|
+
TX_HASH=$(python3 -c "
|
|
269
|
+
from stellar_sdk import Keypair, Server, Network, Asset, TransactionBuilder
|
|
270
|
+
kp = Keypair.from_secret('S...')
|
|
271
|
+
server = Server('https://horizon.stellar.org')
|
|
272
|
+
acct = server.load_account(kp.public_key)
|
|
273
|
+
tx = (TransactionBuilder(acct, Network.PUBLIC_NETWORK_PASSPHRASE, base_fee=100)
|
|
274
|
+
.add_text_memo('$PAYMENT_ID'[:28])
|
|
275
|
+
.append_payment_op('$PAY_TO', Asset('USDC','GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'), '$AMOUNT')
|
|
276
|
+
.set_timeout(30).build())
|
|
277
|
+
tx.sign(kp)
|
|
278
|
+
print(server.submit_transaction(tx)['hash'])
|
|
279
|
+
")
|
|
280
|
+
|
|
281
|
+
# 3. Retry with payment proof → get data
|
|
282
|
+
curl -s -X POST "$GATEWAY/tools/token_price/call" \
|
|
283
|
+
-H "Content-Type: application/json" \
|
|
284
|
+
-H "X-Payment: tx_hash=$TX_HASH,from=$AGENT_ADDR,id=$PAYMENT_ID" \
|
|
285
|
+
-d "{\"parameters\":{\"symbol\":\"ETH\"},\"agent_address\":\"$AGENT_ADDR\"}"
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Session API reference
|
|
291
|
+
|
|
292
|
+
```python
|
|
293
|
+
# Pre-check price without paying
|
|
294
|
+
price = session.estimate("dune_query") # "$0.005"
|
|
295
|
+
|
|
296
|
+
# Check headroom before committing
|
|
297
|
+
if not session.would_exceed("0.005"):
|
|
298
|
+
result = session.call("dune_query", {"query_id": 3810512, "limit": 10})
|
|
299
|
+
|
|
300
|
+
# Access spend state mid-session
|
|
301
|
+
session.spent() # "$0.004"
|
|
302
|
+
session.remaining() # "$0.046"
|
|
303
|
+
|
|
304
|
+
# Full breakdown after session closes
|
|
305
|
+
summary = session.summary()
|
|
306
|
+
# {
|
|
307
|
+
# "calls": 3,
|
|
308
|
+
# "spent_usdc": "0.007",
|
|
309
|
+
# "spent_fmt": "$0.007",
|
|
310
|
+
# "remaining_fmt": "$0.043",
|
|
311
|
+
# "breakdown": [
|
|
312
|
+
# {"tool": "funding_rates", "amount_usdc": "0.003", "tx_hash": "abc123..."},
|
|
313
|
+
# {"tool": "open_interest", "amount_usdc": "0.002", "tx_hash": "def456..."},
|
|
314
|
+
# {"tool": "orderbook_depth", "amount_usdc": "0.002", "tx_hash": "ghi789..."}
|
|
315
|
+
# ]
|
|
316
|
+
# }
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Run the demo
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
git clone https://github.com/romudille-bit/agentpay && cd agentpay
|
|
325
|
+
python -m venv venv && source venv/bin/activate
|
|
326
|
+
pip install -r requirements.txt
|
|
327
|
+
|
|
328
|
+
# Copy env and add your Stellar secret key
|
|
329
|
+
cp .env.example .env
|
|
330
|
+
|
|
331
|
+
# Week 2 demo — open_interest + orderbook_depth on mainnet ($0.004)
|
|
332
|
+
WEEK2_NETWORK=mainnet STELLAR_SECRET_KEY=S... python agent/week2_test.py
|
|
333
|
+
|
|
334
|
+
# Full 5-tool ETH analysis (~$0.012)
|
|
335
|
+
AGENTPAY_GATEWAY_URL=https://gateway-production-2cc2.up.railway.app \
|
|
336
|
+
python agent/budget_demo.py
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Architecture
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
agent (Python SDK)
|
|
345
|
+
│
|
|
346
|
+
│ POST /tools/{name}/call
|
|
347
|
+
│ ← 402 {payment_options: {stellar: {...}, base: {...}}}
|
|
348
|
+
│ → Stellar USDC payment (~3–5s) OR Base transferWithAuthorization (~2s)
|
|
349
|
+
│ → retry with X-Payment or PAYMENT-SIGNATURE header
|
|
350
|
+
│ ← 200 {result: ...}
|
|
351
|
+
▼
|
|
352
|
+
gateway (FastAPI on Railway)
|
|
353
|
+
│
|
|
354
|
+
├── registry/registry.py — 14-tool catalog with prices & dev wallets
|
|
355
|
+
├── gateway/stellar.py — Stellar payment verification via Horizon
|
|
356
|
+
├── gateway/base.py — Base payment verification via JSON-RPC
|
|
357
|
+
└── gateway/main.py — real API dispatchers
|
|
358
|
+
├── CoinGecko token_price, token_market_data
|
|
359
|
+
├── Etherscan V2 gas_tracker, whale_activity, wallet_balance
|
|
360
|
+
├── DeFiLlama defi_tvl, yield_scanner
|
|
361
|
+
├── alternative.me fear_greed_index
|
|
362
|
+
├── Reddit crypto_news
|
|
363
|
+
├── Dune Analytics dune_query
|
|
364
|
+
├── GoPlus token_security
|
|
365
|
+
└── Binance+Bybit+OKX funding_rates, open_interest, orderbook_depth
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Fee model**: Gateway charges 15% (`GATEWAY_FEE_PERCENT=0.15`), forwards the rest to each tool developer's Stellar wallet. All payments settle on-chain in ~3–5 seconds.
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Discovery
|
|
373
|
+
|
|
374
|
+
### Directories & Listings
|
|
375
|
+
|
|
376
|
+
| Directory | Status |
|
|
377
|
+
|-----------|--------|
|
|
378
|
+
| [x402scout](https://x402scout.com) | ✅ indexed, health-checked every 15min |
|
|
379
|
+
| [Glama MCP](https://glama.ai/mcp/servers/romudille-bit/agentpay) | ✅ listed |
|
|
380
|
+
| [402index.io](https://402index.io) | 🔜 needs update — 14 tools |
|
|
381
|
+
| [awesome-x402](https://github.com/xpaysh/awesome-x402) | ✅ listed |
|
|
382
|
+
| [npm](https://www.npmjs.com/package/@romudille/agentpay-mcp) | 🔜 v1.1.0 pending publish |
|
|
383
|
+
| [xpay.tools](https://xpay.tools) | 🔜 submission in progress |
|
|
384
|
+
|
|
385
|
+
### Agent-Readable Endpoints
|
|
386
|
+
|
|
387
|
+
AgentPay is discoverable by autonomous agents at standard well-known paths:
|
|
388
|
+
|
|
389
|
+
| Endpoint | Purpose |
|
|
390
|
+
|----------|---------|
|
|
391
|
+
| `/.well-known/agentpay.json` | AgentPay manifest |
|
|
392
|
+
| `/.well-known/agent.json` | A2A agent card |
|
|
393
|
+
| `/.well-known/l402-services` | 402index.io discovery format |
|
|
394
|
+
| `/llms.txt` | LLM-readable service description (tools + integration guide) |
|
|
395
|
+
| `/sitemap.xml` | 17-URL sitemap |
|
|
396
|
+
|
|
397
|
+
Any x402-compatible agent can discover and use AgentPay tools without human setup.
|