clawdentials-mcp 0.1.0 → 0.7.2

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.
Files changed (35) hide show
  1. package/README.md +310 -58
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +225 -18
  4. package/dist/schemas/index.d.ts +141 -0
  5. package/dist/schemas/index.js +54 -0
  6. package/dist/services/firestore.d.ts +45 -2
  7. package/dist/services/firestore.js +410 -6
  8. package/dist/services/payments/alby.d.ts +104 -0
  9. package/dist/services/payments/alby.js +239 -0
  10. package/dist/services/payments/breez.d.ts +91 -0
  11. package/dist/services/payments/breez.js +267 -0
  12. package/dist/services/payments/cashu.d.ts +127 -0
  13. package/dist/services/payments/cashu.js +248 -0
  14. package/dist/services/payments/coinremitter.d.ts +84 -0
  15. package/dist/services/payments/coinremitter.js +176 -0
  16. package/dist/services/payments/index.d.ts +132 -0
  17. package/dist/services/payments/index.js +180 -0
  18. package/dist/services/payments/oxapay.d.ts +89 -0
  19. package/dist/services/payments/oxapay.js +221 -0
  20. package/dist/services/payments/x402.d.ts +61 -0
  21. package/dist/services/payments/x402.js +94 -0
  22. package/dist/services/payments/zbd.d.ts +88 -0
  23. package/dist/services/payments/zbd.js +221 -0
  24. package/dist/tools/admin.d.ts +195 -0
  25. package/dist/tools/admin.js +210 -0
  26. package/dist/tools/agent.d.ts +197 -0
  27. package/dist/tools/agent.js +200 -0
  28. package/dist/tools/escrow.d.ts +74 -16
  29. package/dist/tools/escrow.js +139 -28
  30. package/dist/tools/index.d.ts +3 -0
  31. package/dist/tools/index.js +3 -0
  32. package/dist/tools/payment.d.ts +144 -0
  33. package/dist/tools/payment.js +376 -0
  34. package/dist/types/index.d.ts +44 -1
  35. package/package.json +18 -2
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Unified Payment Service
3
+ *
4
+ * Provides a single interface for all payment rails:
5
+ * - USDC via x402 on Base
6
+ * - USDT via OxaPay on TRC-20 (and other networks)
7
+ * - BTC via Cashu on Lightning (no KYC, privacy-preserving)
8
+ */
9
+ import type { Currency, PaymentNetwork, Deposit } from '../../types/index.js';
10
+ export { x402Service } from './x402.js';
11
+ export { oxapayService } from './oxapay.js';
12
+ export { cashuService } from './cashu.js';
13
+ export { breezService } from './breez.js';
14
+ export { oxapayService as coinremitterService } from './oxapay.js';
15
+ export { breezService as albyService } from './breez.js';
16
+ export { breezService as zbdService } from './breez.js';
17
+ export interface CreateDepositRequest {
18
+ agentId: string;
19
+ amount: number;
20
+ currency: 'USDC' | 'USDT' | 'BTC';
21
+ description?: string;
22
+ }
23
+ export interface CreateDepositResponse {
24
+ success: boolean;
25
+ deposit?: Partial<Deposit>;
26
+ paymentInstructions?: {
27
+ currency: Currency;
28
+ network: PaymentNetwork;
29
+ address?: string;
30
+ url?: string;
31
+ amount: number;
32
+ amountRaw?: string;
33
+ expiresAt?: Date;
34
+ qrData?: string;
35
+ };
36
+ error?: string;
37
+ }
38
+ export interface SendWithdrawalRequest {
39
+ currency: 'USDC' | 'USDT' | 'BTC';
40
+ amount: number;
41
+ destination: string;
42
+ }
43
+ export interface SendWithdrawalResponse {
44
+ success: boolean;
45
+ txId?: string;
46
+ error?: string;
47
+ }
48
+ /**
49
+ * Create a deposit request for any supported currency
50
+ */
51
+ export declare function createDeposit(request: CreateDepositRequest): Promise<CreateDepositResponse>;
52
+ /**
53
+ * Send a withdrawal in any supported currency
54
+ */
55
+ export declare function sendWithdrawal(request: SendWithdrawalRequest): Promise<SendWithdrawalResponse>;
56
+ /**
57
+ * Get configuration status for all payment providers
58
+ */
59
+ export declare function getPaymentConfig(): {
60
+ usdc: {
61
+ configured: boolean;
62
+ network: string;
63
+ provider: string;
64
+ };
65
+ usdt: {
66
+ configured: boolean;
67
+ network: string;
68
+ provider: string;
69
+ };
70
+ btc: {
71
+ configured: boolean;
72
+ network: string;
73
+ provider: string;
74
+ };
75
+ };
76
+ export declare const paymentService: {
77
+ createDeposit: typeof createDeposit;
78
+ sendWithdrawal: typeof sendWithdrawal;
79
+ getConfig: typeof getPaymentConfig;
80
+ x402: {
81
+ createDeposit: typeof import("./x402.js").createX402Deposit;
82
+ verifyPayment: typeof import("./x402.js").verifyX402Payment;
83
+ sendWithdrawal: typeof import("./x402.js").sendX402Withdrawal;
84
+ config: {
85
+ facilitatorUrl: string;
86
+ walletAddress: string;
87
+ network: string;
88
+ };
89
+ };
90
+ oxapay: {
91
+ createDeposit: typeof import("./oxapay.js").createOxaPayDeposit;
92
+ getPaymentStatus: typeof import("./oxapay.js").getPaymentStatus;
93
+ parseWebhookPayload: typeof import("./oxapay.js").parseWebhookPayload;
94
+ verifyWebhook: typeof import("./oxapay.js").verifyWebhook;
95
+ sendPayout: typeof import("./oxapay.js").sendOxaPayPayout;
96
+ getSupportedCurrencies: typeof import("./oxapay.js").getSupportedCurrencies;
97
+ testConnection: typeof import("./oxapay.js").testConnection;
98
+ config: {
99
+ configured: boolean;
100
+ webhookUrl: string;
101
+ };
102
+ };
103
+ cashu: {
104
+ config: {
105
+ readonly configured: boolean;
106
+ readonly mintUrl: string;
107
+ };
108
+ createDeposit: typeof import("./cashu.js").createDeposit;
109
+ checkDepositAndMint: typeof import("./cashu.js").checkDepositAndMint;
110
+ payInvoice: typeof import("./cashu.js").payInvoice;
111
+ sendToken: typeof import("./cashu.js").sendToken;
112
+ receiveToken: typeof import("./cashu.js").receiveToken;
113
+ calculateBalance: typeof import("./cashu.js").calculateBalance;
114
+ checkProofsSpendable: typeof import("./cashu.js").checkProofsSpendable;
115
+ };
116
+ breez: {
117
+ createDeposit: typeof import("./breez.js").createBreezDeposit;
118
+ sendPayment: typeof import("./breez.js").sendBreezPayment;
119
+ getWalletBalance: typeof import("./breez.js").getWalletBalance;
120
+ listPayments: typeof import("./breez.js").listPayments;
121
+ disconnect: typeof import("./breez.js").disconnect;
122
+ usdToSats: (usd: number) => number;
123
+ satsToUsd: (sats: number) => number;
124
+ config: {
125
+ configured: boolean;
126
+ apiKeySet: boolean;
127
+ mnemonicSet: boolean;
128
+ network: string;
129
+ satsPerUsd: number;
130
+ };
131
+ };
132
+ };
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Unified Payment Service
3
+ *
4
+ * Provides a single interface for all payment rails:
5
+ * - USDC via x402 on Base
6
+ * - USDT via OxaPay on TRC-20 (and other networks)
7
+ * - BTC via Cashu on Lightning (no KYC, privacy-preserving)
8
+ */
9
+ import { x402Service } from './x402.js';
10
+ import { oxapayService } from './oxapay.js';
11
+ import { cashuService } from './cashu.js';
12
+ import { breezService } from './breez.js';
13
+ export { x402Service } from './x402.js';
14
+ export { oxapayService } from './oxapay.js';
15
+ export { cashuService } from './cashu.js';
16
+ export { breezService } from './breez.js';
17
+ // Legacy exports for backwards compatibility
18
+ export { oxapayService as coinremitterService } from './oxapay.js';
19
+ export { breezService as albyService } from './breez.js';
20
+ export { breezService as zbdService } from './breez.js';
21
+ /**
22
+ * Create a deposit request for any supported currency
23
+ */
24
+ export async function createDeposit(request) {
25
+ switch (request.currency) {
26
+ case 'USDC': {
27
+ const result = await x402Service.createDeposit({
28
+ amount: request.amount,
29
+ agentId: request.agentId,
30
+ description: request.description,
31
+ });
32
+ if (!result.success) {
33
+ return { success: false, error: result.error };
34
+ }
35
+ return {
36
+ success: true,
37
+ deposit: result.deposit,
38
+ paymentInstructions: {
39
+ currency: 'USDC',
40
+ network: 'base',
41
+ address: result.paymentDetails?.payTo,
42
+ amount: request.amount,
43
+ amountRaw: result.paymentDetails?.amount,
44
+ expiresAt: result.deposit?.expiresAt || undefined,
45
+ qrData: result.paymentDetails?.payTo, // EVM address for QR
46
+ },
47
+ };
48
+ }
49
+ case 'USDT': {
50
+ const result = await oxapayService.createDeposit({
51
+ amount: request.amount,
52
+ agentId: request.agentId,
53
+ description: request.description,
54
+ });
55
+ if (!result.success) {
56
+ return { success: false, error: result.error };
57
+ }
58
+ return {
59
+ success: true,
60
+ deposit: result.deposit,
61
+ paymentInstructions: {
62
+ currency: 'USDT',
63
+ network: 'trc20',
64
+ address: undefined, // OxaPay uses payment URL instead of direct address
65
+ url: result.invoice?.paymentUrl,
66
+ amount: request.amount,
67
+ expiresAt: result.deposit?.expiresAt || undefined,
68
+ qrData: result.invoice?.paymentUrl, // QR links to payment page
69
+ },
70
+ };
71
+ }
72
+ case 'BTC': {
73
+ // Use Cashu for BTC - no KYC, privacy-preserving ecash
74
+ const result = await cashuService.createDeposit({
75
+ amount: request.amount, // Amount in sats
76
+ agentId: request.agentId,
77
+ description: request.description,
78
+ });
79
+ if (!result.success) {
80
+ return { success: false, error: result.error };
81
+ }
82
+ return {
83
+ success: true,
84
+ deposit: {
85
+ id: result.quote?.quoteId,
86
+ agentId: request.agentId,
87
+ amount: request.amount,
88
+ currency: 'BTC',
89
+ status: 'pending',
90
+ provider: 'cashu',
91
+ createdAt: new Date(),
92
+ expiresAt: result.quote?.expiresAt,
93
+ },
94
+ paymentInstructions: {
95
+ currency: 'BTC',
96
+ network: 'lightning',
97
+ address: result.quote?.bolt11, // Lightning invoice
98
+ amount: request.amount,
99
+ amountRaw: result.quote?.amount?.toString(),
100
+ expiresAt: result.quote?.expiresAt,
101
+ qrData: result.quote?.bolt11, // Lightning invoice for QR
102
+ },
103
+ };
104
+ }
105
+ default:
106
+ return {
107
+ success: false,
108
+ error: `Unsupported currency: ${request.currency}. Supported: USDC, USDT, BTC`,
109
+ };
110
+ }
111
+ }
112
+ /**
113
+ * Send a withdrawal in any supported currency
114
+ */
115
+ export async function sendWithdrawal(request) {
116
+ switch (request.currency) {
117
+ case 'USDC': {
118
+ const result = await x402Service.sendWithdrawal(request.destination, request.amount);
119
+ return {
120
+ success: result.success,
121
+ txId: result.txHash,
122
+ error: result.error,
123
+ };
124
+ }
125
+ case 'USDT': {
126
+ const result = await oxapayService.sendPayout(request.destination, request.amount, 'USDT', 'TRC20');
127
+ return {
128
+ success: result.success,
129
+ txId: result.txId,
130
+ error: result.error,
131
+ };
132
+ }
133
+ case 'BTC': {
134
+ // BTC withdrawals via Cashu require stored proofs
135
+ // This is handled at a higher level in the payment tools
136
+ // where we track agent's ecash proofs in Firestore
137
+ return {
138
+ success: false,
139
+ error: 'BTC withdrawal requires proofs. Use withdraw_crypto tool with stored Cashu proofs.',
140
+ };
141
+ }
142
+ default:
143
+ return {
144
+ success: false,
145
+ error: `Unsupported currency: ${request.currency}. Supported: USDC, USDT, BTC`,
146
+ };
147
+ }
148
+ }
149
+ /**
150
+ * Get configuration status for all payment providers
151
+ */
152
+ export function getPaymentConfig() {
153
+ return {
154
+ usdc: {
155
+ configured: !!x402Service.config.walletAddress,
156
+ network: 'Base L2',
157
+ provider: 'x402 (Coinbase)',
158
+ },
159
+ usdt: {
160
+ configured: oxapayService.config.configured,
161
+ network: 'Tron TRC-20',
162
+ provider: 'OxaPay',
163
+ },
164
+ btc: {
165
+ configured: cashuService.config.configured,
166
+ network: 'Lightning (Cashu)',
167
+ provider: 'Cashu ecash',
168
+ },
169
+ };
170
+ }
171
+ export const paymentService = {
172
+ createDeposit,
173
+ sendWithdrawal,
174
+ getConfig: getPaymentConfig,
175
+ // Individual services for advanced use
176
+ x402: x402Service,
177
+ oxapay: oxapayService,
178
+ cashu: cashuService,
179
+ breez: breezService, // Legacy, kept for backwards compatibility
180
+ };
@@ -0,0 +1,89 @@
1
+ /**
2
+ * OxaPay Payment Service - USDT (and other cryptos)
3
+ *
4
+ * Uses OxaPay API v1 for USDT deposits and withdrawals.
5
+ * Docs: https://docs.oxapay.com
6
+ * Fee: 0.4%
7
+ */
8
+ import type { Deposit } from '../../types/index.js';
9
+ export interface OxaPayPaymentRequest {
10
+ amount: number;
11
+ agentId: string;
12
+ description?: string;
13
+ currency?: string;
14
+ }
15
+ export interface OxaPayPaymentResponse {
16
+ success: boolean;
17
+ deposit?: Partial<Deposit>;
18
+ invoice?: {
19
+ trackId: string;
20
+ paymentUrl: string;
21
+ expiredAt: number;
22
+ };
23
+ error?: string;
24
+ }
25
+ /**
26
+ * Create a USDT deposit invoice via OxaPay
27
+ */
28
+ export declare function createOxaPayDeposit(request: OxaPayPaymentRequest): Promise<OxaPayPaymentResponse>;
29
+ /**
30
+ * Check payment status
31
+ */
32
+ export declare function getPaymentStatus(trackId: string): Promise<{
33
+ success: boolean;
34
+ status?: string;
35
+ paid?: boolean;
36
+ amount?: number;
37
+ txId?: string;
38
+ error?: string;
39
+ }>;
40
+ /**
41
+ * Process webhook callback from OxaPay
42
+ */
43
+ export declare function parseWebhookPayload(body: Record<string, any>): {
44
+ trackId: string;
45
+ status: string;
46
+ amount: number;
47
+ orderId: string;
48
+ txId: string | null;
49
+ };
50
+ /**
51
+ * Verify webhook signature (OxaPay uses HMAC SHA512)
52
+ */
53
+ export declare function verifyWebhook(body: string, signature: string): boolean;
54
+ /**
55
+ * Send USDT payout via OxaPay
56
+ */
57
+ export declare function sendOxaPayPayout(toAddress: string, amount: number, currency?: string, network?: string): Promise<{
58
+ success: boolean;
59
+ txId?: string;
60
+ error?: string;
61
+ }>;
62
+ /**
63
+ * Get supported currencies and networks
64
+ */
65
+ export declare function getSupportedCurrencies(): Promise<{
66
+ success: boolean;
67
+ currencies?: any[];
68
+ error?: string;
69
+ }>;
70
+ /**
71
+ * Test API connection
72
+ */
73
+ export declare function testConnection(): Promise<{
74
+ success: boolean;
75
+ error?: string;
76
+ }>;
77
+ export declare const oxapayService: {
78
+ createDeposit: typeof createOxaPayDeposit;
79
+ getPaymentStatus: typeof getPaymentStatus;
80
+ parseWebhookPayload: typeof parseWebhookPayload;
81
+ verifyWebhook: typeof verifyWebhook;
82
+ sendPayout: typeof sendOxaPayPayout;
83
+ getSupportedCurrencies: typeof getSupportedCurrencies;
84
+ testConnection: typeof testConnection;
85
+ config: {
86
+ configured: boolean;
87
+ webhookUrl: string;
88
+ };
89
+ };
@@ -0,0 +1,221 @@
1
+ /**
2
+ * OxaPay Payment Service - USDT (and other cryptos)
3
+ *
4
+ * Uses OxaPay API v1 for USDT deposits and withdrawals.
5
+ * Docs: https://docs.oxapay.com
6
+ * Fee: 0.4%
7
+ */
8
+ // Configuration
9
+ const OXAPAY_API_KEY = process.env.OXAPAY_API_KEY || '';
10
+ const OXAPAY_WEBHOOK_URL = process.env.OXAPAY_WEBHOOK_URL || '';
11
+ // API base URL
12
+ const API_BASE = 'https://api.oxapay.com/v1';
13
+ /**
14
+ * Make API request to OxaPay v1
15
+ */
16
+ async function apiRequest(endpoint, data) {
17
+ if (!OXAPAY_API_KEY) {
18
+ throw new Error('OXAPAY_API_KEY not configured');
19
+ }
20
+ const response = await fetch(`${API_BASE}${endpoint}`, {
21
+ method: 'POST',
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ 'merchant_api_key': OXAPAY_API_KEY,
25
+ },
26
+ body: JSON.stringify(data),
27
+ });
28
+ const result = await response.json();
29
+ if (result.status !== 200) {
30
+ throw new Error(result.message || `OxaPay API error: ${result.status}`);
31
+ }
32
+ return result;
33
+ }
34
+ /**
35
+ * Create a USDT deposit invoice via OxaPay
36
+ */
37
+ export async function createOxaPayDeposit(request) {
38
+ if (!OXAPAY_API_KEY) {
39
+ return {
40
+ success: false,
41
+ error: 'OXAPAY_API_KEY not configured. Set this environment variable.',
42
+ };
43
+ }
44
+ try {
45
+ const orderId = `clw_${request.agentId}_${Date.now()}`;
46
+ const result = await apiRequest('/payment/invoice', {
47
+ amount: request.amount,
48
+ currency: 'USD',
49
+ to_currency: request.currency || 'USDT',
50
+ lifetime: 30, // 30 minutes
51
+ order_id: orderId,
52
+ description: request.description || `Deposit for ${request.agentId}`,
53
+ callback_url: OXAPAY_WEBHOOK_URL || undefined,
54
+ fee_paid_by_payer: 0, // We pay the fee
55
+ sandbox: false,
56
+ });
57
+ const expiresAt = new Date(result.data.expired_at * 1000);
58
+ return {
59
+ success: true,
60
+ deposit: {
61
+ id: `oxapay_${result.data.track_id}`,
62
+ agentId: request.agentId,
63
+ amount: request.amount,
64
+ currency: 'USDT',
65
+ network: 'trc20',
66
+ status: 'pending',
67
+ provider: 'oxapay',
68
+ externalId: result.data.track_id,
69
+ paymentAddress: null, // OxaPay uses payment URL instead
70
+ paymentUrl: result.data.payment_url,
71
+ createdAt: new Date(),
72
+ expiresAt,
73
+ completedAt: null,
74
+ txHash: null,
75
+ },
76
+ invoice: {
77
+ trackId: result.data.track_id,
78
+ paymentUrl: result.data.payment_url,
79
+ expiredAt: result.data.expired_at,
80
+ },
81
+ };
82
+ }
83
+ catch (error) {
84
+ return {
85
+ success: false,
86
+ error: error instanceof Error ? error.message : 'Failed to create invoice',
87
+ };
88
+ }
89
+ }
90
+ /**
91
+ * Check payment status
92
+ */
93
+ export async function getPaymentStatus(trackId) {
94
+ if (!OXAPAY_API_KEY) {
95
+ return { success: false, error: 'OXAPAY_API_KEY not configured' };
96
+ }
97
+ try {
98
+ const result = await apiRequest('/payment/inquiry', {
99
+ track_id: trackId,
100
+ });
101
+ // OxaPay statuses: Waiting, Confirming, Paid, Failed, Expired
102
+ return {
103
+ success: true,
104
+ status: result.data.status,
105
+ paid: result.data.status === 'Paid',
106
+ amount: parseFloat(result.data.amount || '0'),
107
+ txId: result.data.txID,
108
+ };
109
+ }
110
+ catch (error) {
111
+ return {
112
+ success: false,
113
+ error: error instanceof Error ? error.message : 'Failed to get payment status',
114
+ };
115
+ }
116
+ }
117
+ /**
118
+ * Process webhook callback from OxaPay
119
+ */
120
+ export function parseWebhookPayload(body) {
121
+ return {
122
+ trackId: body.track_id,
123
+ status: body.status,
124
+ amount: parseFloat(body.amount || '0'),
125
+ orderId: body.order_id, // Contains agentId
126
+ txId: body.txID || null,
127
+ };
128
+ }
129
+ /**
130
+ * Verify webhook signature (OxaPay uses HMAC SHA512)
131
+ */
132
+ export function verifyWebhook(body, signature) {
133
+ if (!OXAPAY_API_KEY)
134
+ return false;
135
+ const crypto = require('crypto');
136
+ const hmac = crypto.createHmac('sha512', OXAPAY_API_KEY);
137
+ hmac.update(body);
138
+ const calculatedSignature = hmac.digest('hex');
139
+ return calculatedSignature === signature;
140
+ }
141
+ /**
142
+ * Send USDT payout via OxaPay
143
+ */
144
+ export async function sendOxaPayPayout(toAddress, amount, currency = 'USDT', network = 'TRC20') {
145
+ if (!OXAPAY_API_KEY) {
146
+ return { success: false, error: 'OXAPAY_API_KEY not configured' };
147
+ }
148
+ try {
149
+ const result = await apiRequest('/payment/payout', {
150
+ address: toAddress,
151
+ amount,
152
+ currency,
153
+ network,
154
+ callback_url: OXAPAY_WEBHOOK_URL || undefined,
155
+ description: 'Clawdentials withdrawal',
156
+ });
157
+ return {
158
+ success: true,
159
+ txId: result.data.track_id,
160
+ };
161
+ }
162
+ catch (error) {
163
+ return {
164
+ success: false,
165
+ error: error instanceof Error ? error.message : 'Failed to send payout',
166
+ };
167
+ }
168
+ }
169
+ /**
170
+ * Get supported currencies and networks
171
+ */
172
+ export async function getSupportedCurrencies() {
173
+ if (!OXAPAY_API_KEY) {
174
+ return { success: false, error: 'OXAPAY_API_KEY not configured' };
175
+ }
176
+ try {
177
+ const result = await apiRequest('/payment/currencies', {});
178
+ return {
179
+ success: true,
180
+ currencies: result.data,
181
+ };
182
+ }
183
+ catch (error) {
184
+ return {
185
+ success: false,
186
+ error: error instanceof Error ? error.message : 'Failed to get currencies',
187
+ };
188
+ }
189
+ }
190
+ /**
191
+ * Test API connection
192
+ */
193
+ export async function testConnection() {
194
+ if (!OXAPAY_API_KEY) {
195
+ return { success: false, error: 'OXAPAY_API_KEY not configured' };
196
+ }
197
+ try {
198
+ // Try to get currencies as a simple API test
199
+ await getSupportedCurrencies();
200
+ return { success: true };
201
+ }
202
+ catch (error) {
203
+ return {
204
+ success: false,
205
+ error: error instanceof Error ? error.message : 'API connection failed',
206
+ };
207
+ }
208
+ }
209
+ export const oxapayService = {
210
+ createDeposit: createOxaPayDeposit,
211
+ getPaymentStatus,
212
+ parseWebhookPayload,
213
+ verifyWebhook,
214
+ sendPayout: sendOxaPayPayout,
215
+ getSupportedCurrencies,
216
+ testConnection,
217
+ config: {
218
+ configured: !!OXAPAY_API_KEY,
219
+ webhookUrl: OXAPAY_WEBHOOK_URL,
220
+ },
221
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * x402 Payment Service - USDC on Base
3
+ *
4
+ * Uses Coinbase's x402 protocol for instant stablecoin payments.
5
+ * Docs: https://docs.cdp.coinbase.com/x402/welcome
6
+ */
7
+ import type { Deposit } from '../../types/index.js';
8
+ export interface X402PaymentRequest {
9
+ amount: number;
10
+ agentId: string;
11
+ description?: string;
12
+ }
13
+ export interface X402PaymentResponse {
14
+ success: boolean;
15
+ deposit?: Partial<Deposit>;
16
+ paymentDetails?: {
17
+ payTo: string;
18
+ amount: string;
19
+ network: string;
20
+ facilitatorUrl: string;
21
+ };
22
+ error?: string;
23
+ }
24
+ /**
25
+ * Create a payment request for USDC via x402
26
+ *
27
+ * For x402, the flow is different - it's typically used as middleware
28
+ * where the client pays before accessing a resource. For deposits,
29
+ * we generate payment details that the agent can use to send USDC.
30
+ */
31
+ export declare function createX402Deposit(request: X402PaymentRequest): Promise<X402PaymentResponse>;
32
+ /**
33
+ * Verify a payment was received via x402
34
+ *
35
+ * In production, this would check the blockchain or use the x402 facilitator
36
+ * to verify the payment. For now, we provide a manual verification endpoint.
37
+ */
38
+ export declare function verifyX402Payment(txHash: string, expectedAmount: number): Promise<{
39
+ success: boolean;
40
+ verified: boolean;
41
+ amount?: number;
42
+ error?: string;
43
+ }>;
44
+ /**
45
+ * Send USDC withdrawal via x402/Base
46
+ */
47
+ export declare function sendX402Withdrawal(toAddress: string, amount: number): Promise<{
48
+ success: boolean;
49
+ txHash?: string;
50
+ error?: string;
51
+ }>;
52
+ export declare const x402Service: {
53
+ createDeposit: typeof createX402Deposit;
54
+ verifyPayment: typeof verifyX402Payment;
55
+ sendWithdrawal: typeof sendX402Withdrawal;
56
+ config: {
57
+ facilitatorUrl: string;
58
+ walletAddress: string;
59
+ network: string;
60
+ };
61
+ };