pay-lobster 1.0.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 +401 -0
- package/README.md.bak +401 -0
- package/dist/agent.d.ts +132 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +224 -0
- package/dist/agent.js.map +1 -0
- package/dist/analytics.d.ts +120 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +345 -0
- package/dist/analytics.js.map +1 -0
- package/dist/approvals.d.ts +168 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +406 -0
- package/dist/approvals.js.map +1 -0
- package/dist/circle-client.d.ts +152 -0
- package/dist/circle-client.d.ts.map +1 -0
- package/dist/circle-client.js +266 -0
- package/dist/circle-client.js.map +1 -0
- package/dist/commission.d.ts +191 -0
- package/dist/commission.d.ts.map +1 -0
- package/dist/commission.js +475 -0
- package/dist/commission.js.map +1 -0
- package/dist/condition-builder.d.ts +98 -0
- package/dist/condition-builder.d.ts.map +1 -0
- package/dist/condition-builder.js +193 -0
- package/dist/condition-builder.js.map +1 -0
- package/dist/contacts.d.ts +179 -0
- package/dist/contacts.d.ts.map +1 -0
- package/dist/contacts.js +445 -0
- package/dist/contacts.js.map +1 -0
- package/dist/easy.d.ts +22 -0
- package/dist/easy.d.ts.map +1 -0
- package/dist/easy.js +40 -0
- package/dist/easy.js.map +1 -0
- package/dist/erc8004/constants.d.ts +152 -0
- package/dist/erc8004/constants.d.ts.map +1 -0
- package/dist/erc8004/constants.js +114 -0
- package/dist/erc8004/constants.js.map +1 -0
- package/dist/erc8004/discovery.d.ts +84 -0
- package/dist/erc8004/discovery.d.ts.map +1 -0
- package/dist/erc8004/discovery.js +217 -0
- package/dist/erc8004/discovery.js.map +1 -0
- package/dist/erc8004/identity.d.ts +91 -0
- package/dist/erc8004/identity.d.ts.map +1 -0
- package/dist/erc8004/identity.js +250 -0
- package/dist/erc8004/identity.js.map +1 -0
- package/dist/erc8004/index.d.ts +147 -0
- package/dist/erc8004/index.d.ts.map +1 -0
- package/dist/erc8004/index.js +225 -0
- package/dist/erc8004/index.js.map +1 -0
- package/dist/erc8004/reputation.d.ts +133 -0
- package/dist/erc8004/reputation.d.ts.map +1 -0
- package/dist/erc8004/reputation.js +277 -0
- package/dist/erc8004/reputation.js.map +1 -0
- package/dist/escrow-templates.d.ts +38 -0
- package/dist/escrow-templates.d.ts.map +1 -0
- package/dist/escrow-templates.js +419 -0
- package/dist/escrow-templates.js.map +1 -0
- package/dist/escrow.d.ts +320 -0
- package/dist/escrow.d.ts.map +1 -0
- package/dist/escrow.js +854 -0
- package/dist/escrow.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.d.ts +212 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +393 -0
- package/dist/invoices.js.map +1 -0
- package/dist/notifications.d.ts +141 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +350 -0
- package/dist/notifications.js.map +1 -0
- package/dist/tips.d.ts +171 -0
- package/dist/tips.d.ts.map +1 -0
- package/dist/tips.js +390 -0
- package/dist/tips.js.map +1 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/x402-client.d.ts +127 -0
- package/dist/x402-client.d.ts.map +1 -0
- package/dist/x402-client.js +350 -0
- package/dist/x402-client.js.map +1 -0
- package/dist/x402-server.d.ts +133 -0
- package/dist/x402-server.d.ts.map +1 -0
- package/dist/x402-server.js +330 -0
- package/dist/x402-server.js.map +1 -0
- package/lib/agent.ts +273 -0
- package/lib/analytics.ts +474 -0
- package/lib/analytics.ts.bak +474 -0
- package/lib/approvals.ts +585 -0
- package/lib/approvals.ts.bak +585 -0
- package/lib/circle-client.ts +376 -0
- package/lib/circle-client.ts.bak +376 -0
- package/lib/commission.ts +680 -0
- package/lib/commission.ts.bak +680 -0
- package/lib/condition-builder.ts +223 -0
- package/lib/condition-builder.ts.bak +223 -0
- package/lib/contacts.ts +615 -0
- package/lib/contacts.ts.bak +615 -0
- package/lib/easy.ts +46 -0
- package/lib/easy.ts.bak +352 -0
- package/lib/erc8004/constants.ts +175 -0
- package/lib/erc8004/discovery.ts +299 -0
- package/lib/erc8004/identity.ts +327 -0
- package/lib/erc8004/index.ts +285 -0
- package/lib/erc8004/reputation.ts +368 -0
- package/lib/escrow-templates.ts +462 -0
- package/lib/escrow.ts +1216 -0
- package/lib/index.ts +13 -0
- package/lib/invoices.ts +588 -0
- package/lib/notifications.ts +484 -0
- package/lib/tips.ts +570 -0
- package/lib/types.ts +108 -0
- package/lib/x402-client.ts +471 -0
- package/lib/x402-server.ts +462 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# 🦞 Pay Lobster
|
|
2
|
+
|
|
3
|
+
> **The Stripe for AI Agents.** Let your agent hire other agents, pay for APIs, and get paid for work — all without you lifting a finger.
|
|
4
|
+
|
|
5
|
+
**Built on Base** 🔵 | **Circle USDC Hackathon 2026** 🏆
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### Why Pay Lobster?
|
|
10
|
+
|
|
11
|
+
| You Are | Your Problem | Pay Lobster Solution |
|
|
12
|
+
|---------|--------------|---------------------|
|
|
13
|
+
| **AI Developer** | "My agent needs to pay for APIs" | One-line wallet setup, auto-pay |
|
|
14
|
+
| **Agent Builder** | "How do I monetize my agent?" | Accept payments, tips, subscriptions |
|
|
15
|
+
| **Business** | "I don't trust AI agents" | Escrow + trust scores verify reliability |
|
|
16
|
+
| **Freelancer** | "Clients don't pay on time" | Smart escrow auto-releases on milestones |
|
|
17
|
+
| **API Provider** | "I want per-request pricing" | x402 micropayments ($0.001/call) |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ✨ Highlights
|
|
22
|
+
|
|
23
|
+
- **ERC-8004 Trustless Agents** — On-chain identity & reputation for AI agents
|
|
24
|
+
- **x402 Payment Protocol** — HTTP-native micropayments for AI agents
|
|
25
|
+
- **Escrow as a Service** — Pre-built templates for any industry
|
|
26
|
+
- **Agent-to-Agent Commerce** — Autonomous payments between bots with trust verification
|
|
27
|
+
- **Multi-Chain Support** — Ethereum, Polygon, Avalanche, Arbitrum, Base
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
### 🆔 ERC-8004 Trustless Agents (NEW)
|
|
32
|
+
- 🪪 **On-Chain Identity** — NFT-based agent registration
|
|
33
|
+
- ⭐ **Reputation System** — Feedback & ratings after transactions
|
|
34
|
+
- 🔍 **Agent Discovery** — Find trusted agents by capability
|
|
35
|
+
- ✅ **Trust Verification** — Verify agents before paying them
|
|
36
|
+
- 📊 **Payment Safety** — Risk-based payment limits by trust score
|
|
37
|
+
- 🤝 **Post-Transaction Feedback** — Build reputation through use
|
|
38
|
+
|
|
39
|
+
### 🔐 x402 Payment Protocol (NEW)
|
|
40
|
+
- 💳 **HTTP-Native Payments** — `402 Payment Required` → automatic USDC payment
|
|
41
|
+
- 🤖 **Agent Commerce** — Bots pay bots for API calls, data, services
|
|
42
|
+
- 🧾 **Payment Receipts** — On-chain proof of payment
|
|
43
|
+
- 🔄 **Automatic Retry** — Handle payment challenges seamlessly
|
|
44
|
+
- 📊 **Usage Tracking** — Track spend by endpoint, recipient, time
|
|
45
|
+
|
|
46
|
+
### 🏦 Escrow as a Service (NEW)
|
|
47
|
+
- 🏠 **Real Estate** — Earnest money, security deposits, rent
|
|
48
|
+
- 💼 **Freelance** — Milestone payments, hourly billing
|
|
49
|
+
- 🛒 **Commerce** — Buyer protection, marketplace escrow
|
|
50
|
+
- 🤝 **P2P** — Peer-to-peer trades with trusted release
|
|
51
|
+
- ⚙️ **Custom** — Build your own with condition DSL
|
|
52
|
+
|
|
53
|
+
### Core Wallet Operations
|
|
54
|
+
- 💰 **Check USDC balances** across multiple chains
|
|
55
|
+
- 📤 **Send USDC** to any address or contact name
|
|
56
|
+
- 📥 **Receive USDC** with generated addresses
|
|
57
|
+
- 🌉 **Cross-chain transfers** via Circle's CCTP
|
|
58
|
+
- 🤖 **Agent-to-agent payments** for autonomous commerce
|
|
59
|
+
|
|
60
|
+
### Invoicing & Billing
|
|
61
|
+
- 📄 **Invoice Creation** — Professional invoices with line items, tax
|
|
62
|
+
- 📧 **Invoice Delivery** — Send via email, Telegram, etc.
|
|
63
|
+
- ✅ **Payment Tracking** — Draft → Sent → Viewed → Paid lifecycle
|
|
64
|
+
- 🔗 **Payment Links** — EIP-681 style payment request URLs
|
|
65
|
+
- ⏰ **Overdue Detection** — Automatic status updates
|
|
66
|
+
|
|
67
|
+
### Recurring Payments
|
|
68
|
+
- 🔄 **Subscriptions** — Daily, weekly, biweekly, monthly, quarterly, yearly
|
|
69
|
+
- ⏸️ **Flexible Control** — Pause, resume, cancel anytime
|
|
70
|
+
- 📊 **Payment History** — Full execution history with tx hashes
|
|
71
|
+
|
|
72
|
+
### Address Book
|
|
73
|
+
- 👥 **Contacts** — Store names with multiple chain addresses
|
|
74
|
+
- 🏷️ **Tags & Search** — Organize and find contacts
|
|
75
|
+
- 🎯 **Name Resolution** — Send to "Alice" instead of 0x addresses
|
|
76
|
+
- 📋 **Import/Export** — CSV support for bulk operations
|
|
77
|
+
|
|
78
|
+
### Security & Approvals
|
|
79
|
+
- 🛡️ **Approval Policies** — Require approval for large transactions
|
|
80
|
+
- 👥 **Multi-Approver** — Configurable number of required approvals
|
|
81
|
+
- 💵 **Daily Limits** — Auto-trigger approval when limit exceeded
|
|
82
|
+
- ⏰ **Timeout Handling** — Auto-cancel or auto-approve on expiry
|
|
83
|
+
|
|
84
|
+
### Notifications
|
|
85
|
+
- 🔔 **Real-Time Alerts** — Incoming payments, large outgoing, etc.
|
|
86
|
+
- 🌐 **Webhook Support** — POST to external URLs with HMAC signatures
|
|
87
|
+
- 💬 **Clawdbot Integration** — Notifications via Telegram, etc.
|
|
88
|
+
- ⏱️ **Rate Limiting** — Configurable cooldowns to prevent spam
|
|
89
|
+
|
|
90
|
+
### Analytics & Reporting
|
|
91
|
+
- 📊 **Daily Summaries** — Sent, received, net per day
|
|
92
|
+
- 📈 **Category Breakdown** — Spending analysis by category
|
|
93
|
+
- 👤 **Contact Analysis** — Volume by contact, top recipients
|
|
94
|
+
- 🔗 **Chain Distribution** — Activity breakdown across chains
|
|
95
|
+
- 📤 **CSV Export** — Export transactions for accounting
|
|
96
|
+
|
|
97
|
+
### Tip Jar / Creator Economy
|
|
98
|
+
- 💰 **Tip Jars** — Let your community tip you in USDC
|
|
99
|
+
- 🏆 **Leaderboards** — Top tippers weekly/monthly/all-time
|
|
100
|
+
- 🎉 **Real-Time Notifications** — Get notified instantly on tips
|
|
101
|
+
- 🤖 **Agent-to-Agent Tips** — Clawdbots can tip each other
|
|
102
|
+
|
|
103
|
+
### Real Estate Escrow
|
|
104
|
+
- 🏠 **Earnest Money** — Hold deposits with condition-based release
|
|
105
|
+
- 🔑 **Security Deposits** — Rental deposits with move-out inspection
|
|
106
|
+
- 📋 **Conditions** — Inspection, financing, title, custom conditions
|
|
107
|
+
- ✍️ **Multi-Party Approval** — Buyer + seller sign-off for release
|
|
108
|
+
- 📄 **Document Tracking** — Attach contracts, inspection reports
|
|
109
|
+
|
|
110
|
+
## Quick Start
|
|
111
|
+
|
|
112
|
+
### 1. Get Circle Credentials
|
|
113
|
+
|
|
114
|
+
Sign up at [console.circle.com](https://console.circle.com) and create:
|
|
115
|
+
- API Key (Keys → Create a key → API key → Standard Key)
|
|
116
|
+
- Entity Secret
|
|
117
|
+
|
|
118
|
+
### 2. Set Environment Variables
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
export CIRCLE_API_KEY="your-api-key"
|
|
122
|
+
export CIRCLE_ENTITY_SECRET="your-entity-secret"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 3. Install & Setup
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
cd skills/lobster-pay
|
|
129
|
+
npm install
|
|
130
|
+
npm run setup
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 4. Use It
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Check balance
|
|
137
|
+
npm run balance
|
|
138
|
+
|
|
139
|
+
# Send USDC
|
|
140
|
+
npx ts-node scripts/usdc-cli.ts send 10 to 0x1234...
|
|
141
|
+
|
|
142
|
+
# Get receive address
|
|
143
|
+
npm run receive
|
|
144
|
+
|
|
145
|
+
# Bridge across chains
|
|
146
|
+
npx ts-node scripts/usdc-cli.ts bridge 100 from ETH-SEPOLIA to AVAX-FUJI
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Architecture
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
lobster-pay/
|
|
153
|
+
├── SKILL.md # OpenClaw skill documentation
|
|
154
|
+
├── README.md # This file
|
|
155
|
+
├── package.json # Dependencies
|
|
156
|
+
├── lib/
|
|
157
|
+
│ ├── circle-client.ts # Circle Programmable Wallets API client
|
|
158
|
+
│ ├── x402-client.ts # x402 payment protocol client
|
|
159
|
+
│ ├── x402-server.ts # x402 payment verification middleware
|
|
160
|
+
│ ├── escrow.ts # Escrow management & multi-party release
|
|
161
|
+
│ ├── escrow-templates.ts # Pre-built escrow templates
|
|
162
|
+
│ ├── condition-builder.ts # Flexible condition DSL
|
|
163
|
+
│ └── erc8004/ # ERC-8004 Trustless Agents
|
|
164
|
+
│ ├── index.ts # Main client & helpers
|
|
165
|
+
│ ├── identity.ts # Identity Registry (agent registration)
|
|
166
|
+
│ ├── reputation.ts # Reputation Registry (feedback)
|
|
167
|
+
│ ├── discovery.ts # Agent discovery service
|
|
168
|
+
│ └── constants.ts # Contract addresses & types
|
|
169
|
+
│ ├── invoices.ts # Invoice & recurring payment management
|
|
170
|
+
│ ├── contacts.ts # Address book & contact resolution
|
|
171
|
+
│ ├── approvals.ts # Multi-sig style approval workflows
|
|
172
|
+
│ ├── notifications.ts # Real-time alerts & webhooks
|
|
173
|
+
│ └── analytics.ts # Transaction analytics & reporting
|
|
174
|
+
├── scripts/
|
|
175
|
+
│ └── usdc-cli.ts # CLI tool for testing
|
|
176
|
+
├── docs/
|
|
177
|
+
│ ├── erc8004-integration.md # ERC-8004 Trustless Agents guide
|
|
178
|
+
│ ├── x402-integration.md # x402 protocol documentation
|
|
179
|
+
│ ├── x402-quickstart.md # Quick start guide
|
|
180
|
+
│ ├── escrow-templates.md # Escrow template reference
|
|
181
|
+
│ └── ARCHITECTURE.md # Technical architecture
|
|
182
|
+
├── examples/
|
|
183
|
+
│ ├── x402-client-example.ts
|
|
184
|
+
│ └── x402-server-example.ts
|
|
185
|
+
└── data/ # Local data storage (created at runtime)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Supported Networks (Testnet)
|
|
189
|
+
|
|
190
|
+
| Network | Chain ID | USDC Contract |
|
|
191
|
+
|---------|----------|---------------|
|
|
192
|
+
| Ethereum Sepolia | ETH-SEPOLIA | Circle managed |
|
|
193
|
+
| Polygon Amoy | MATIC-AMOY | Circle managed |
|
|
194
|
+
| Avalanche Fuji | AVAX-FUJI | Circle managed |
|
|
195
|
+
| Arbitrum Sepolia | ARB-SEPOLIA | Circle managed |
|
|
196
|
+
|
|
197
|
+
## API Overview
|
|
198
|
+
|
|
199
|
+
### CircleClient
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
import { CircleClient } from './lib/circle-client';
|
|
203
|
+
|
|
204
|
+
const client = new CircleClient({
|
|
205
|
+
apiKey: process.env.CIRCLE_API_KEY!,
|
|
206
|
+
entitySecret: process.env.CIRCLE_ENTITY_SECRET!,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Get balances
|
|
210
|
+
const balances = await client.getAllUSDCBalances();
|
|
211
|
+
|
|
212
|
+
// Send USDC
|
|
213
|
+
const tx = await client.sendUSDC({
|
|
214
|
+
fromWalletId: 'wallet-id',
|
|
215
|
+
toAddress: '0x...',
|
|
216
|
+
amount: '100',
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Bridge via CCTP
|
|
220
|
+
const bridge = await client.bridgeUSDC({
|
|
221
|
+
fromWalletId: 'wallet-id',
|
|
222
|
+
toAddress: '0x...',
|
|
223
|
+
fromChain: 'ETH-SEPOLIA',
|
|
224
|
+
toChain: 'AVAX-FUJI',
|
|
225
|
+
amount: '50',
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### InvoiceManager
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { InvoiceManager } from './lib/invoices';
|
|
233
|
+
|
|
234
|
+
const invoices = new InvoiceManager();
|
|
235
|
+
|
|
236
|
+
// Create invoice
|
|
237
|
+
const invoice = await invoices.create({
|
|
238
|
+
from: { name: 'My Business', walletAddress: '0x...' },
|
|
239
|
+
to: { name: 'Client Corp', email: 'billing@client.com' },
|
|
240
|
+
items: [
|
|
241
|
+
{ description: 'Web Development', quantity: 1, unitPrice: '500' },
|
|
242
|
+
{ description: 'Hosting (monthly)', quantity: 3, unitPrice: '50' },
|
|
243
|
+
],
|
|
244
|
+
taxRate: 8.25,
|
|
245
|
+
dueDate: '2026-03-01',
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Track payments
|
|
249
|
+
await invoices.markPaid(invoice.id, '0xtxhash...');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### ContactManager
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { ContactManager } from './lib/contacts';
|
|
256
|
+
|
|
257
|
+
const contacts = new ContactManager();
|
|
258
|
+
|
|
259
|
+
// Add contact
|
|
260
|
+
await contacts.add({
|
|
261
|
+
name: 'Alice Smith',
|
|
262
|
+
alias: 'alice',
|
|
263
|
+
addresses: [
|
|
264
|
+
{ chain: 'ETH-SEPOLIA', address: '0x...' },
|
|
265
|
+
{ chain: 'AVAX-FUJI', address: '0x...' },
|
|
266
|
+
],
|
|
267
|
+
tags: ['vendor', 'priority'],
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Resolve recipient (by name or address)
|
|
271
|
+
const recipient = await contacts.resolveRecipient('alice', 'ETH-SEPOLIA');
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### ApprovalManager
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import { ApprovalManager } from './lib/approvals';
|
|
278
|
+
|
|
279
|
+
const approvals = new ApprovalManager();
|
|
280
|
+
|
|
281
|
+
// Create policy
|
|
282
|
+
await approvals.createPolicy({
|
|
283
|
+
name: 'Large Transactions',
|
|
284
|
+
conditions: { minAmount: '1000' },
|
|
285
|
+
approvers: ['owner-session-id'],
|
|
286
|
+
requiredApprovals: 1,
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Submit for approval
|
|
290
|
+
const pending = await approvals.submitForApproval({
|
|
291
|
+
type: 'send',
|
|
292
|
+
fromWalletId: '...',
|
|
293
|
+
toAddress: '0x...',
|
|
294
|
+
amount: '5000',
|
|
295
|
+
chain: 'ETH-SEPOLIA',
|
|
296
|
+
requestedBy: 'agent',
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Approve
|
|
300
|
+
await approvals.decide(pending.id, 'owner-session-id', 'approve');
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### x402Client
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
import { X402Client } from './lib/x402-client';
|
|
307
|
+
|
|
308
|
+
const x402 = new X402Client({
|
|
309
|
+
circleClient,
|
|
310
|
+
walletId: 'your-wallet-id',
|
|
311
|
+
chain: 'ETH-SEPOLIA',
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Make a paid API call (auto-handles 402 responses)
|
|
315
|
+
const response = await x402.fetch('https://api.example.com/premium-data', {
|
|
316
|
+
method: 'GET',
|
|
317
|
+
maxPayment: '1.00', // Max USDC willing to pay
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Check payment history
|
|
321
|
+
const receipts = x402.getPaymentReceipts();
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### ERC8004Client (Trustless Agents)
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { createERC8004Client } from './lib/erc8004';
|
|
328
|
+
|
|
329
|
+
const erc8004 = createERC8004Client('BASE-SEPOLIA', privateKey, {
|
|
330
|
+
paymentAddress: '0x...',
|
|
331
|
+
x402Endpoint: 'https://my-agent.com/x402',
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Register your agent
|
|
335
|
+
const agentId = await erc8004.registerAgent({
|
|
336
|
+
name: 'My Pay Lobster',
|
|
337
|
+
description: 'AI agent accepting USDC payments',
|
|
338
|
+
capabilities: ['payments', 'escrow', 'invoicing'],
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// Verify another agent before paying
|
|
342
|
+
const verification = await erc8004.verifyAgent(targetAgentId);
|
|
343
|
+
if (verification.verified && verification.recommendation === 'safe') {
|
|
344
|
+
// Proceed with payment
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Check payment safety
|
|
348
|
+
const safety = await erc8004.isPaymentSafe(targetAgentId, 500);
|
|
349
|
+
// => { safe: true, maxRecommendedAmount: 1000, trustScore: 82 }
|
|
350
|
+
|
|
351
|
+
// Post feedback after transaction
|
|
352
|
+
await erc8004.postPaymentSuccess(targetAgentId, txHash, '100');
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### EscrowManager with Templates
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
import { EscrowManager } from './lib/escrow';
|
|
359
|
+
import { EscrowTemplates } from './lib/escrow-templates';
|
|
360
|
+
|
|
361
|
+
const escrow = new EscrowManager({ circleClient });
|
|
362
|
+
|
|
363
|
+
// Use a pre-built template
|
|
364
|
+
const freelanceEscrow = await escrow.createFromTemplate(
|
|
365
|
+
EscrowTemplates.freelance.milestone({
|
|
366
|
+
client: '0xClient...',
|
|
367
|
+
freelancer: '0xFreelancer...',
|
|
368
|
+
milestones: [
|
|
369
|
+
{ name: 'Design', amount: '500' },
|
|
370
|
+
{ name: 'Development', amount: '1500' },
|
|
371
|
+
{ name: 'Launch', amount: '500' },
|
|
372
|
+
],
|
|
373
|
+
})
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
// Or build custom conditions
|
|
377
|
+
import { ConditionBuilder } from './lib/condition-builder';
|
|
378
|
+
|
|
379
|
+
const conditions = new ConditionBuilder()
|
|
380
|
+
.requireSignatures(['buyer', 'seller'])
|
|
381
|
+
.requireDocument('inspection_report')
|
|
382
|
+
.addTimelock(7 * 24 * 60 * 60 * 1000) // 7 days
|
|
383
|
+
.build();
|
|
384
|
+
|
|
385
|
+
const customEscrow = await escrow.create({
|
|
386
|
+
buyer: '0x...',
|
|
387
|
+
seller: '0x...',
|
|
388
|
+
amount: '10000',
|
|
389
|
+
conditions,
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Testnet Faucets
|
|
394
|
+
|
|
395
|
+
Get testnet USDC:
|
|
396
|
+
- **Circle Faucet**: https://faucet.circle.com/
|
|
397
|
+
- **Sepolia ETH**: https://sepoliafaucet.com/
|
|
398
|
+
|
|
399
|
+
## License
|
|
400
|
+
|
|
401
|
+
MIT - Built with ❤️ for Circle USDC Hackathon 2026
|