moltspay 0.2.9 → 0.2.10

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/dist/cli.mjs CHANGED
@@ -415,6 +415,57 @@ var init_AgentWallet = __esm({
415
415
  };
416
416
  }
417
417
  }
418
+ /**
419
+ * Pay for a service (transfer USDC to service provider)
420
+ *
421
+ * This is the main method for Agent-to-Agent payments.
422
+ * Returns payment data ready to submit to service API.
423
+ *
424
+ * @example
425
+ * ```typescript
426
+ * const wallet = new AgentWallet({ chain: 'base' });
427
+ *
428
+ * // Pay for Zen7 video service
429
+ * const payment = await wallet.payService({
430
+ * provider: '0xb8d6f2441e8f8dfB6288A74Cf73804cDd0484E0C',
431
+ * amount: 0.99,
432
+ * service: 'video_generation'
433
+ * });
434
+ *
435
+ * if (payment.success) {
436
+ * // Submit to service API
437
+ * await fetch('/v1/video/generate', {
438
+ * body: JSON.stringify({
439
+ * prompt: "...",
440
+ * payment: payment.paymentData // Ready to use!
441
+ * })
442
+ * });
443
+ * }
444
+ * ```
445
+ */
446
+ async payService(params) {
447
+ const result = await this.transfer({
448
+ to: params.provider,
449
+ amount: params.amount
450
+ });
451
+ if (result.success && result.txHash) {
452
+ return {
453
+ success: true,
454
+ txHash: result.txHash,
455
+ explorerUrl: result.explorerUrl,
456
+ paymentData: {
457
+ method: "transfer",
458
+ chain: this.chain,
459
+ tx_hash: result.txHash
460
+ }
461
+ };
462
+ } else {
463
+ return {
464
+ success: false,
465
+ error: result.error
466
+ };
467
+ }
468
+ }
418
469
  /**
419
470
  * Get gas balance (ETH needed for transactions)
420
471
  */