paytaca-cli 0.1.0 → 0.3.0
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.
- package/README.md +91 -12
- package/dist/commands/address.d.ts +2 -0
- package/dist/commands/address.d.ts.map +1 -1
- package/dist/commands/address.js +19 -4
- package/dist/commands/address.js.map +1 -1
- package/dist/commands/balance.d.ts +2 -0
- package/dist/commands/balance.d.ts.map +1 -1
- package/dist/commands/balance.js +58 -12
- package/dist/commands/balance.js.map +1 -1
- package/dist/commands/check.d.ts +14 -0
- package/dist/commands/check.d.ts.map +1 -0
- package/dist/commands/check.js +162 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/claude.d.ts +9 -0
- package/dist/commands/claude.d.ts.map +1 -0
- package/dist/commands/claude.js +20 -0
- package/dist/commands/claude.js.map +1 -0
- package/dist/commands/history.d.ts +2 -0
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +40 -7
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/opencode.d.ts +9 -0
- package/dist/commands/opencode.d.ts.map +1 -0
- package/dist/commands/opencode.js +20 -0
- package/dist/commands/opencode.js.map +1 -0
- package/dist/commands/pay.d.ts +17 -0
- package/dist/commands/pay.d.ts.map +1 -0
- package/dist/commands/pay.js +347 -0
- package/dist/commands/pay.js.map +1 -0
- package/dist/commands/receive.d.ts +9 -1
- package/dist/commands/receive.d.ts.map +1 -1
- package/dist/commands/receive.js +117 -8
- package/dist/commands/receive.js.map +1 -1
- package/dist/commands/token.d.ts +16 -0
- package/dist/commands/token.d.ts.map +1 -0
- package/dist/commands/token.js +351 -0
- package/dist/commands/token.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/types/x402.d.ts +72 -0
- package/dist/types/x402.d.ts.map +1 -0
- package/dist/types/x402.js +9 -0
- package/dist/types/x402.js.map +1 -0
- package/dist/utils/skill.d.ts +17 -0
- package/dist/utils/skill.d.ts.map +1 -0
- package/dist/utils/skill.js +100 -0
- package/dist/utils/skill.js.map +1 -0
- package/dist/utils/x402.d.ts +17 -0
- package/dist/utils/x402.d.ts.map +1 -0
- package/dist/utils/x402.js +119 -0
- package/dist/utils/x402.js.map +1 -0
- package/dist/utils/x402.test.d.ts +2 -0
- package/dist/utils/x402.test.d.ts.map +1 -0
- package/dist/utils/x402.test.js +216 -0
- package/dist/utils/x402.test.js.map +1 -0
- package/dist/wallet/bch.d.ts +110 -3
- package/dist/wallet/bch.d.ts.map +1 -1
- package/dist/wallet/bch.js +214 -2
- package/dist/wallet/bch.js.map +1 -1
- package/dist/wallet/keys.d.ts +8 -0
- package/dist/wallet/keys.d.ts.map +1 -1
- package/dist/wallet/keys.js +10 -0
- package/dist/wallet/keys.js.map +1 -1
- package/dist/wallet/x402.d.ts +29 -0
- package/dist/wallet/x402.d.ts.map +1 -0
- package/dist/wallet/x402.js +45 -0
- package/dist/wallet/x402.js.map +1 -0
- package/package.json +8 -2
- package/skills/paytaca/SKILL.md +123 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: paytaca-x402
|
|
3
|
+
description: Handles x402 HTTP payment requests using Paytaca BCH wallet. Use when encountering HTTP 402 responses or when calling APIs that may require payment via the x402 protocol.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Paytaca x402 Payment Handler
|
|
7
|
+
|
|
8
|
+
This skill teaches the agent how to handle x402-based HTTP payments using the Paytaca CLI wallet.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Some APIs (like nanogpt, etc.) use the x402 protocol for HTTP payments. When you call these APIs:
|
|
13
|
+
- Server returns **HTTP 402 PAYMENT REQUIRED**
|
|
14
|
+
- You must pay with BCH to access the resource
|
|
15
|
+
- After payment, the server returns the actual response
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### Check if a URL requires payment (recommended first step)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
paytaca check <url> --json
|
|
23
|
+
# Returns: acceptsX402, acceptsBch, estimatedCostSats, etc.
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Example output:
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"url": "https://api.nanogpt.com/v1/complete",
|
|
30
|
+
"acceptsX402": true,
|
|
31
|
+
"acceptsBch": true,
|
|
32
|
+
"paymentRequired": true,
|
|
33
|
+
"estimatedCostSats": "100",
|
|
34
|
+
"costInBch": "0.00000100"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Preview payment without executing (dry-run)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
paytaca pay <url> --dry-run --json
|
|
42
|
+
# Shows what would happen without actually paying
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Make a paid request
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Basic
|
|
49
|
+
paytaca pay <url>
|
|
50
|
+
|
|
51
|
+
# With JSON output (preferred for AI agents)
|
|
52
|
+
paytaca pay <url> --json
|
|
53
|
+
|
|
54
|
+
# POST request
|
|
55
|
+
paytaca pay <url> --method POST --body '{"prompt":"hello"}'
|
|
56
|
+
|
|
57
|
+
# Custom headers
|
|
58
|
+
paytaca pay <url> -H "Authorization: Bearer token123"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Check wallet balance
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
paytaca balance
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Decision Flow
|
|
68
|
+
|
|
69
|
+
When preparing to call an unfamiliar API that might require payment:
|
|
70
|
+
|
|
71
|
+
1. **First check**: `paytaca check <url> --json`
|
|
72
|
+
- If `paymentRequired: false` → proceed normally
|
|
73
|
+
- If `paymentRequired: true` and `acceptsBch: true` → inform user of cost and **seek explicit approval** before paying
|
|
74
|
+
- If `paymentRequired: true` but `acceptsBch: false` → inform user
|
|
75
|
+
|
|
76
|
+
2. **When encountering HTTP 402**:
|
|
77
|
+
- Parse the `PAYMENT-REQUIRED` headers
|
|
78
|
+
- **Seek explicit user approval** before spending any BCH
|
|
79
|
+
- Once approved, use `paytaca pay <url> --json` to handle payment
|
|
80
|
+
- The command handles: parse headers → build BCH tx → broadcast → retry with signature
|
|
81
|
+
|
|
82
|
+
3. **For known paid APIs**:
|
|
83
|
+
- **Always seek user approval first**, then use `paytaca pay <url>` - it handles 402 automatically
|
|
84
|
+
|
|
85
|
+
## ⚠️ User Approval Required Before Any Payment
|
|
86
|
+
|
|
87
|
+
**CRITICAL**: The agent MUST NOT execute `paytaca pay` without explicit user approval. Since `paytaca pay` spends real BCH from the user's wallet, always:
|
|
88
|
+
|
|
89
|
+
1. Inform the user of the cost (e.g., "This API costs ~1000 sats")
|
|
90
|
+
2. Wait for explicit user confirmation (e.g., "yes", "go ahead", "pay")
|
|
91
|
+
3. Only then execute the payment
|
|
92
|
+
|
|
93
|
+
Do NOT assume the user wants to pay - even if the cost seems small.
|
|
94
|
+
|
|
95
|
+
## AI Agent Workflow
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
Task: Call nanogpt API
|
|
99
|
+
Agent: paytaca check https://api.nanogpt.com/v1/complete --json
|
|
100
|
+
→ {"acceptsBch": true, "estimatedCostSats": "100"}
|
|
101
|
+
|
|
102
|
+
Agent: Informs user "This API costs 100 sats (0.00000100 BCH). Approve to proceed?"
|
|
103
|
+
User: "yes"
|
|
104
|
+
|
|
105
|
+
Agent: paytaca pay https://api.nanogpt.com/v1/complete --method POST --body '{"prompt":"hello"}' --json
|
|
106
|
+
→ Handles 402 → pays 100 sats → returns response with txid
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Key Options
|
|
110
|
+
|
|
111
|
+
| Option | Description |
|
|
112
|
+
|--------|-------------|
|
|
113
|
+
| `--json` | Machine-readable output (recommended for AI) |
|
|
114
|
+
| `--dry-run` | Preview payment without executing |
|
|
115
|
+
| `--chipnet` | Use chipnet (testnet) instead of mainnet |
|
|
116
|
+
| `--max-amount` | Override max payment amount in sats |
|
|
117
|
+
|
|
118
|
+
## Notes
|
|
119
|
+
|
|
120
|
+
- Payment is per-request (no batching)
|
|
121
|
+
- Each request = separate BCH transaction
|
|
122
|
+
- Only BCH payments are supported (no stablecoins)
|
|
123
|
+
- Uses local wallet from OS keychain (credentials never leave the machine)
|