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.js CHANGED
@@ -436,6 +436,57 @@ var init_AgentWallet = __esm({
436
436
  };
437
437
  }
438
438
  }
439
+ /**
440
+ * Pay for a service (transfer USDC to service provider)
441
+ *
442
+ * This is the main method for Agent-to-Agent payments.
443
+ * Returns payment data ready to submit to service API.
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * const wallet = new AgentWallet({ chain: 'base' });
448
+ *
449
+ * // Pay for Zen7 video service
450
+ * const payment = await wallet.payService({
451
+ * provider: '0xb8d6f2441e8f8dfB6288A74Cf73804cDd0484E0C',
452
+ * amount: 0.99,
453
+ * service: 'video_generation'
454
+ * });
455
+ *
456
+ * if (payment.success) {
457
+ * // Submit to service API
458
+ * await fetch('/v1/video/generate', {
459
+ * body: JSON.stringify({
460
+ * prompt: "...",
461
+ * payment: payment.paymentData // Ready to use!
462
+ * })
463
+ * });
464
+ * }
465
+ * ```
466
+ */
467
+ async payService(params) {
468
+ const result = await this.transfer({
469
+ to: params.provider,
470
+ amount: params.amount
471
+ });
472
+ if (result.success && result.txHash) {
473
+ return {
474
+ success: true,
475
+ txHash: result.txHash,
476
+ explorerUrl: result.explorerUrl,
477
+ paymentData: {
478
+ method: "transfer",
479
+ chain: this.chain,
480
+ tx_hash: result.txHash
481
+ }
482
+ };
483
+ } else {
484
+ return {
485
+ success: false,
486
+ error: result.error
487
+ };
488
+ }
489
+ }
439
490
  /**
440
491
  * Get gas balance (ETH needed for transactions)
441
492
  */