Skip to main content

Python SDK for MoltsPay - Agent-to-Agent Payments

Project description

MoltsPay Python SDK

Python SDK for MoltsPay - Agent-to-Agent Payments.

Installation

pip install moltspay

Quick Start

from moltspay import MoltsPay

# Initialize (auto-creates wallet if not exists)
client = MoltsPay()
print(f"Wallet address: {client.address}")

# Discover services
services = client.discover("https://juai8.com/zen7")
for svc in services:
    print(f"{svc.id}: {svc.price} {svc.currency}")

# Pay for a service
result = client.pay(
    "https://juai8.com/zen7",
    "text-to-video",
    prompt="a cat dancing on the beach"
)
print(result.result)

Features

  • Auto wallet management - Creates wallet on first run, compatible with Node.js CLI
  • Spending limits - Set per-transaction and daily limits
  • x402 protocol - Native support for HTTP 402 payment flow
  • Gasless payments - Uses EIP-2612 permits, no ETH needed for clients

Wallet Management

from moltspay import MoltsPay

# Wallet auto-created at ~/.moltspay/wallet.json
client = MoltsPay()

# Check limits
limits = client.limits()
print(f"Max per tx: {limits.max_per_tx}")
print(f"Spent today: {limits.spent_today}")

# Update limits
client.set_limits(max_per_tx=20, max_per_day=200)

Async Support

import asyncio
from moltspay import AsyncMoltsPay

async def main():
    async with AsyncMoltsPay() as client:
        result = await client.pay(
            "https://juai8.com/zen7",
            "text-to-video",
            prompt="a cat dancing"
        )
        print(result.result)

asyncio.run(main())

Error Handling

from moltspay import MoltsPay, InsufficientFunds, LimitExceeded, PaymentError

client = MoltsPay()

try:
    result = client.pay(...)
except InsufficientFunds as e:
    print(f"Need {e.required} USDC, have {e.balance}")
except LimitExceeded as e:
    print(f"Exceeds {e.limit_type} limit: {e.amount} > {e.limit}")
except PaymentError as e:
    print(f"Payment failed: {e}")

CLI Compatibility

Wallet format is compatible with Node.js CLI:

# Create wallet with Node CLI
npx moltspay init --chain base

# Use same wallet in Python
python -c "from moltspay import MoltsPay; print(MoltsPay().address)"

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moltspay-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moltspay-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file moltspay-0.1.0.tar.gz.

File metadata

  • Download URL: moltspay-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for moltspay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b99b5e34638ac22e23cbe8b272ae7aacc90f5ef66f453bedfcb40b5ceae7550b
MD5 bc0f685523e8b258f6b509c7ee4215a0
BLAKE2b-256 e90bff7860109fc5610e6e44011a52383aa4e9abd3d2101b5643cca061277c38

See more details on using hashes here.

File details

Details for the file moltspay-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: moltspay-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for moltspay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17cf147ccfca474ddc16d18c68580dff74906c1583587c19a9e102ad25bdfb3b
MD5 3fe67f55f8598abb12283a325042bd99
BLAKE2b-256 3dfe286891d69ef17377f8724aa6d6e34e36577dd570f4d3bd4da5c565aba9a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page