Skip to content

Getting Started

Yaqing2023 edited this page Mar 7, 2026 · 1 revision

Getting Started

Get up and running with MoltsPay Python SDK.

Prerequisites

  • Python 3.9+
  • USDC on Base network

Installation

pip install moltspay

For LangChain integration:

pip install moltspay[langchain]

Step 1: Initialize Client

from moltspay import MoltsPay

client = MoltsPay()
print(f"Wallet address: {client.address}")

On first run, a wallet is automatically created at ~/.moltspay/wallet.json.

Step 2: Fund Your Wallet

Send USDC to your wallet address on Base network.

No ETH needed! MoltsPay uses gasless transactions.

Step 3: Check Balance

print(f"Balance: {client.balance()} USDC")

Step 4: Discover Services

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

Output:

text-to-video: 0.99 USDC
image-to-video: 1.49 USDC

Step 5: Pay for a Service

result = client.pay(
    "https://juai8.com/zen7",
    "text-to-video",
    prompt="a happy cat playing piano"
)

print(f"Video URL: {result.result['video_url']}")

Done! The payment happens automatically via x402.

Setting Spending Limits

Protect your wallet:

# Check current 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 Usage

For high-performance applications:

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())

CLI Compatibility

Wallet format is compatible with the 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)"

Next Steps

Clone this wiki locally