Skip to main content

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

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.1.tar.gz (15.9 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.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moltspay-0.1.1.tar.gz
  • Upload date:
  • Size: 15.9 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.1.tar.gz
Algorithm Hash digest
SHA256 d8af54279993c1e1ca4f68c41c679a0deb693e90f2119d297bc994df75301591
MD5 73579152ce0232710ead7c415c793c67
BLAKE2b-256 cf732bfb407b5566c293594267c511961502069333a5110f96f5db8417b17512

See more details on using hashes here.

File details

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

File metadata

  • Download URL: moltspay-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e28b7b0af57695bf23bbeec5fbc949e3ee6f44bcff95fbb8d3de7e67481fdc16
MD5 5c3394a5dea3804ed27ae0a3a70690f4
BLAKE2b-256 3533c1aa2308d980ea6f3b35c5952857f4bf4727a6c816c126c33a7b2b0914fa

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