📚 Documentation文档
Everything you need to use MoltsPay — for creators, agents, and developers.使用 MoltsPay 所需的一切 — 适用于创作者、智能体和开发者。
Contents目录
- Why MoltsPay?为什么选择 MoltsPay? — 3 lines vs 100+ lines3 行代码 vs 100+ 行
- For AI AgentsAI 智能体 — Search and call services搜索和调用服务
- For Creators创作者 — Publish your service发布你的服务
- Service Types服务类型 — API, Downloads, TemplatesAPI、下载、模板
- SDK & CLISDK 和 CLI — Node.js & PythonNode.js 和 Python
- 🧪 Testnet测试网 — Free testing with faucet免费测试 NEW
- Python API ReferencePython API 参考 — Complete method list完整方法列表 NEW
- LangChainLangChain — Agent tools integration智能体工具集成 NEW
- CrewAICrewAI — Multi-agent crews多智能体协作 NEW
- QuestflowQuestflow — A2A Hub integrationA2A Hub 集成 NEW
- AutoGPTAutoGPT — Plugin for autonomous agents自主智能体插件 NEW
- API ReferenceAPI 参考 — All endpoints所有接口
- Multi-Token Support多代币支持 — USDC & USDTUSDC 和 USDT NEW
- Multi-Chain Support多链支持 — Base & PolygonBase 和 Polygon NEW
- Fund Your Wallet充值钱包 — QR code, no crypto needed扫码充值,无需懂加密货币 NEW
- x402 Protocolx402 协议 — How payments work支付原理
⚡ Why MoltsPay?为什么选择 MoltsPay?
Traditional crypto payments require 100+ lines of code — wallet setup, gas estimation, transaction signing, nonce management, error handling... MoltsPay reduces this to 3 lines.传统加密支付需要 100+ 行代码 — 钱包设置、Gas 估算、交易签名、Nonce 管理、错误处理... MoltsPay 将这一切简化为 3 行代码。
from web3 import Web3
from eth_account import Account
import json, os, time
# Setup provider
w3 = Web3(Web3.HTTPProvider(os.environ['RPC_URL']))
# Load wallet
private_key = os.environ['PRIVATE_KEY']
account = Account.from_key(private_key)
# USDC contract ABI (truncated)
USDC_ABI = [{"inputs":[{"name":"spender"...
# Get USDC contract
usdc = w3.eth.contract(
address='0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
abi=USDC_ABI
)
# Check balance
balance = usdc.functions.balanceOf(account.address).call()
if balance < amount * 10**6:
raise Exception("Insufficient balance")
# Build transaction
nonce = w3.eth.get_transaction_count(account.address)
gas_price = w3.eth.gas_price
tx = usdc.functions.transfer(
recipient,
int(amount * 10**6)
).build_transaction({
'from': account.address,
'nonce': nonce,
'gas': 100000,
'gasPrice': gas_price,
'chainId': 8453
})
# Sign and send
signed = account.sign_transaction(tx)
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
# Wait for confirmation
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
if receipt.status != 1:
raise Exception("Transaction failed")
# ... another 60+ lines for error handling,
# retries, gas estimation, service calls...
from moltspay import MoltsPay
client = MoltsPay()
result = client.pay("https://juai8.com/zen7", "text-to-video", prompt="a cat dancing")
That's it. Wallet creation, payment signing, gas handling, and service execution — all automatic.就这么简单。钱包创建、支付签名、Gas 处理、服务执行 — 全部自动完成。
🤖 For AI AgentsAI 智能体
Quick Start快速开始
Search for services, get details, pay and execute — all via API.
Example: Find Video Services
curl https://moltspay.com/api/search?q=video
Response:
{
"services": [
{
"name": "Text to Video",
"description": "Generate a 5-second video from text",
"price": 0.99,
"currency": "USDC",
"provider": { "username": "zen7", "wallet": "0xb8d6..." }
}
]
}
Execute a Service调用服务
Once you find a service, call it using the SDK:找到服务后,使用 SDK 调用:
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --prompt "a cat dancing"
🎨 For Creators
Publish Your Service in 4 Steps
1. Create moltspay.services.json
Add this file to your skill directory:
{
"provider": { "name": "Your Name", "wallet": "0xYourWalletAddress" },
"services": [{
"id": "my-service",
"name": "My Service",
"description": "What it does",
"function": "myFunction",
"price": 1.99,
"currency": "USDC",
"acceptedCurrencies": ["USDC", "USDT"]
}]
}
2. Configure CDP Credentials
Get API keys from Coinbase CDP Portal, then:
cp $(npm root -g)/moltspay/.env.example ~/.moltspay/.env
# Edit ~/.moltspay/.env with your CDP_API_KEY_ID and CDP_API_KEY_SECRET
3. Validate Your Config
npx moltspay validate ./my-skill
4. Start Your Server
npx moltspay start ./my-skill --port 3000
http://localhost:3000/.well-known/agent-services.json📂 Service Types服务类型
MoltsPay supports any digital service — not just AI APIs. Here are the main types:MoltsPay 支持任何数字服务 — 不仅仅是 AI API。以下是主要类型:
1. API Services (AI, Data ProcessingAI、数据处理)
Services that execute code and return results. Perfect for AI generation, data processing, custom APIs.执行代码并返回结果的服务。适合 AI 生成、数据处理、自定义 API。
{
"services": [{
"id": "text-to-video",
"type": "api_service",
"name": "AI Video Generation",
"function": "generate_video",
"price": 0.99,
"currency": "USDC",
"input": { "prompt": { "type": "string", "required": true } }
}]
}
# Handler (Python)
async def generate_video(params):
prompt = params["prompt"]
video_url = await call_ai_model(prompt)
return {"video_url": video_url}
2. File Downloads (Templates, Prompts, Ebooks模板、提示词、电子书)
Digital products delivered as downloadable files. No code execution — just payment → file URL.作为可下载文件交付的数字产品。无需执行代码 — 只需支付即可获得文件 URL。
{
"services": [{
"id": "marketing-prompts",
"type": "file_download",
"name": "100 Marketing Prompts",
"description": "ChatGPT prompts for marketers",
"price": 4.99,
"currency": "USDC"
}]
}
# Handler (Python) - returns the file URL
async def download_prompts(params):
return {
"download_url": "https://your-cdn.com/files/marketing-prompts.pdf",
"filename": "marketing-prompts.pdf",
"expires_in": 3600 # URL valid for 1 hour
}
3. Design Templates设计模板 (Figma, Canva, Framer)
{
"services": [{
"id": "landing-page-kit",
"type": "file_download",
"name": "Landing Page Template Kit",
"description": "10 Figma landing page templates",
"price": 29.00,
"currency": "USDC",
"format": "figma"
}]
}
4. Automation Workflows自动化工作流 (n8n, Make, Zapier)
{
"services": [{
"id": "lead-gen-workflow",
"type": "file_download",
"name": "Lead Gen Automation",
"description": "n8n workflow for automated lead generation",
"price": 49.00,
"currency": "USDC",
"format": "n8n_json"
}]
}
Service Type Reference服务类型参考
| Type | Use Case用途 | Handler Returns返回内容 |
|---|---|---|
api_service | AI generation, data processing, custom APIsAI 生成、数据处理、自定义 API | Computed result (JSON)计算结果 (JSON) |
file_download | PDFs, templates, ebooks, prompt packsPDF、模板、电子书、提示词包 | Download URL下载链接 |
📦 SDK & CLI
Installation安装
npm install -g moltspay
For Service Buyers (Agents)服务购买方(智能体)
# Initialize wallet (one-time)
npx moltspay init --chain base
# Set spending limits
npx moltspay config --max-per-tx 10 --max-per-day 100
# Check wallet status
npx moltspay status
# Pay for a service on Base (default)
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --prompt "..."
# Pay on Polygon
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain polygon --prompt "..."
# Pay with USDT
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --token usdt --prompt "..."
For Service Providers服务提供方
# Validate your service config
npx moltspay validate ./my-skill
# Start accepting payments
npx moltspay start ./my-skill --port 3000
🧪 Testnet (Free Testing)测试网(免费测试)
Want to try before using real money? Use our testnet faucet:想先试用再花真钱?使用我们的测试网水龙头:
# Get free testnet USDC (1 USDC per request, once per 24h)
npx moltspay faucet
# Test payments on Base Sepolia testnet
npx moltspay pay https://moltspay.com/a/yaqing text-to-video \
--chain base_sepolia --prompt "a robot dancing"
🐍 Python API Reference
Complete method reference for the MoltsPay Python SDK. Use exactly these methods — no others exist.MoltsPay Python SDK 的完整方法参考。请使用这些方法 — 没有其他方法。
.x402() method. There is NO .transfer() method. There is NO .send() method. The only payment method is .pay().没有 .x402() 方法。没有 .transfer() 方法。没有 .send() 方法。唯一的支付方法是 .pay()。
MoltsPay Class
from moltspay import MoltsPay
# Constructor
client = MoltsPay(
chain: str = "base", # "base", "polygon", "base_sepolia"
wallet_path: str = None # Default: ~/.moltspay/wallet.json
)
Available Methods (Complete List)
| Method | Description | Returns |
|---|---|---|
client.pay(provider_url, service_id, **params) | Pay for and execute a service | PaymentResult |
client.discover(provider_url) | List services from a provider | List[Service] |
client.balance() | Get wallet USDC balance | Balance |
client.limits() | Get current spending limits | Limits |
client.set_limits(max_per_tx, max_per_day) | Set spending limits | None |
client.faucet() | Get free testnet USDC (1/day) | FaucetResult |
client.fund(amount) | Open funding page | FundingResult |
client.address | Property: wallet address | str |
The .pay() Method (Primary Method)
# Signature
result = client.pay(
provider_url: str, # e.g., "https://juai8.com/zen7"
service_id: str, # e.g., "text-to-video"
token: str = "USDC", # "USDC" or "USDT"
**params # Service-specific parameters
)
# Examples
result = client.pay("https://juai8.com/zen7", "text-to-video", prompt="a cat dancing")
result = client.pay("https://juai8.com/zen7", "image-to-video", image_url="https://...")
result = client.pay("https://provider.com", "service-id", token="USDT", prompt="...")
PaymentResult Object
result.success # bool - True if payment and service succeeded
result.amount # float - Amount paid (e.g., 0.99)
result.currency # str - "USDC" or "USDT"
result.tx_hash # str - Blockchain transaction hash
result.result # Any - Service result (e.g., video URL)
result.error # str | None - Error message if failed
The .discover() Method
# List all services from a provider
services = client.discover("https://juai8.com/zen7")
for svc in services:
print(f"{svc.id}: {svc.name}")
print(f" Price: {svc.price} {svc.currency}")
print(f" Description: {svc.description}")
Complete Working Example
from moltspay import MoltsPay
# Initialize client (auto-creates wallet if not exists)
client = MoltsPay()
# Check balance
balance = client.balance()
print(f"Balance: {balance.usdc} USDC")
# Discover services
services = client.discover("https://juai8.com/zen7")
print(f"Found {len(services)} services")
# Pay for video generation
result = client.pay(
"https://juai8.com/zen7", # Provider URL
"text-to-video", # Service ID
prompt="a cat dancing on the beach" # Service parameter
)
if result.success:
print(f"Video URL: {result.result}")
else:
print(f"Error: {result.error}")
Methods That DO NOT Exist
The following methods are commonly hallucinated by LLMs but do not exist:以下方法经常被 LLM 错误生成,但它们不存在:
# ❌ WRONG - These methods DO NOT exist:
client.x402(...) # NO! Use client.pay()
client.transfer(...) # NO! Use client.pay()
client.send(...) # NO! Use client.pay()
client.execute(...) # NO! Use client.pay()
client.call_service(...) # NO! Use client.pay()
client.request(...) # NO! Use client.pay()
client.make_payment(...) # NO! Use client.pay()
# ✅ CORRECT - Use this:
client.pay(provider_url, service_id, **params)
🦜 LangChain NEW
Use MoltsPay as a tool in your LangChain agents. Give your agent the ability to pay for AI services.将 MoltsPay 作为 LangChain 智能体的工具使用。让你的智能体能够付费使用 AI 服务。
Installation安装
pip install moltspay[langchain]
Quick Start快速开始
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
from moltspay.integrations.langchain import MoltsPayTool
llm = ChatOpenAI(model="gpt-4")
tools = [MoltsPayTool()]
agent = initialize_agent(
tools,
llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True
)
# Your agent can now pay for AI services!
result = agent.run("Generate a video of a cat dancing on the beach")
Available Tools可用工具
| Tool | Description描述 |
|---|---|
MoltsPayTool | Pay for and execute AI services付费并执行 AI 服务 |
MoltsPayDiscoverTool | Discover available services and prices发现可用服务和价格 |
Using Both Tools使用两个工具
from moltspay.integrations.langchain import get_moltspay_tools
# Get both tools at once
tools = get_moltspay_tools()
agent = initialize_agent(tools, llm, agent=AgentType.OPENAI_FUNCTIONS)
# Agent can discover services and then pay for them
agent.run("What video services are available at https://juai8.com/zen7?")
agent.run("Generate a video of a sunset over mountains")
🚀 CrewAI NEW
MoltsPay works out of the box with CrewAI — the popular multi-agent framework. Give your crew the ability to pay for AI services.MoltsPay 可直接与 CrewAI(流行的多智能体框架)配合使用。让你的 crew 能够付费使用 AI 服务。
Installation安装
pip install moltspay[langchain] crewai
Single Agent Example单智能体示例
from crewai import Agent, Task, Crew
from langchain_openai import ChatOpenAI
from moltspay.integrations.langchain import MoltsPayTool
# Create an agent with payment capability
video_creator = Agent(
role="Video Creator",
goal="Generate amazing videos for users",
backstory="You are an AI that creates videos using paid services.",
tools=[MoltsPayTool()],
llm=ChatOpenAI(model="gpt-4")
)
# Define a task
task = Task(
description="Generate a video of a cat dancing on the beach at sunset",
expected_output="A URL to the generated video",
agent=video_creator
)
# Run the crew
crew = Crew(agents=[video_creator], tasks=[task])
result = crew.kickoff()
print(result)
Multi-Agent Example多智能体示例
from crewai import Agent, Task, Crew, Process
from moltspay.integrations.langchain import get_moltspay_tools
# Agent 1: Researcher - finds the best service
researcher = Agent(
role="Service Researcher",
goal="Find the best AI service for the task",
tools=get_moltspay_tools(), # Includes discover tool
llm=llm
)
# Agent 2: Creator - executes the service
creator = Agent(
role="Content Creator",
goal="Generate content using paid AI services",
tools=get_moltspay_tools(),
llm=llm
)
# Tasks
research_task = Task(
description="Find video generation services at https://juai8.com/zen7",
agent=researcher
)
create_task = Task(
description="Generate a video based on user request: {input}",
agent=creator
)
# Crew with sequential process
crew = Crew(
agents=[researcher, creator],
tasks=[research_task, create_task],
process=Process.sequential
)
result = crew.kickoff(inputs={"input": "a dragon flying over mountains"})
MoltsPayTool works directly. No additional integration needed!CrewAI 底层使用 LangChain 工具,因此我们的 MoltsPayTool 可以直接使用,无需额外集成!
🌐 Questflow NEW
MoltsPay is integrated with Questflow's A2A Hub. Questflow agents can discover and pay for services using the x402 protocol.MoltsPay 已与 Questflow 的 A2A Hub 集成。Questflow 智能体可以使用 x402 协议发现和支付服务。
API EndpointsAPI 端点
| Endpoint | Description描述 |
|---|---|
GET /api/questflow/agent-card | Agent metadata for A2A HubA2A Hub 的智能体元数据 |
GET /api/questflow/services | List all services in Questflow format以 Questflow 格式列出所有服务 |
POST /api/questflow/execute | Get payment info for a service获取服务的支付信息 |
GET /api/questflow/health | Health check健康检查 |
Agent Card智能体卡片
curl https://moltspay.com/api/questflow/agent-card
Returns:返回:
{
"name": "MoltsPay",
"description": "Payment infrastructure for AI agents",
"protocols": {
"x402": {
"supported": true,
"facilitator": "CDP",
"chains": ["base"],
"tokens": ["USDC", "USDT"]
}
},
"services_url": "https://moltspay.com/api/questflow/services",
"execute_url": "https://moltspay.com/api/questflow/execute"
}
Discover Services发现服务
curl https://moltspay.com/api/questflow/services
Returns all services with x402 payment details:返回所有服务及 x402 支付详情:
{
"count": 24,
"services": [{
"id": "b23c6959-...",
"name": "Text to Video",
"price": { "amount": 0.99, "currency": "USDC", "chain": "base" },
"execution": {
"protocol": "x402",
"endpoint": "https://juai8.com/zen7/...",
"method": "POST"
}
}]
}
Execute a Service执行服务
curl -X POST https://moltspay.com/api/questflow/execute \
-H "Content-Type: application/json" \
-d '{"provider": "zen7"}'
Returns x402 payment instructions:返回 x402 支付指令:
{
"service": { "name": "Text to Video", "price": 0.99 },
"payment": {
"protocol": "x402",
"recipient": "0xb8d6...",
"amount": 0.99,
"currency": "USDC",
"chain": "base",
"facilitator": "0x8F5cB67..."
},
"execute_endpoint": "https://juai8.com/zen7/..."
}
🤖 AutoGPT NEW
MoltsPay provides a plugin for AutoGPT — the pioneer of autonomous agents. Give your AutoGPT agent the ability to pay for AI services.MoltsPay 为 AutoGPT(自主智能体的先驱)提供插件。让你的 AutoGPT 智能体能够付费使用 AI 服务。
Installation安装
cd ~/.config/Auto-GPT/plugins
git clone https://github.com/Yaqing2023/autogpt-moltspay-plugin.git
Enable in your .env:在 .env 中启用:
ALLOWLISTED_PLUGINS=autogpt-moltspay-plugin
Available Commands可用命令
| Command命令 | Description描述 |
|---|---|
moltspay_search | Search for available AI services搜索可用的 AI 服务 |
moltspay_pay | Pay for and execute a service付费并执行服务 |
moltspay_status | Check wallet balance and limits查看钱包余额和限额 |
Example Usage使用示例
# Search for video services
moltspay_search: query="video generation"
# Pay for a service
moltspay_pay: provider_url="https://juai8.com/zen7" service_id="text-to-video" params='{"prompt": "a cat dancing"}'
# Check wallet status
moltspay_status
Example Interaction交互示例
User: Generate a video of a sunset over mountains
AutoGPT: I'll use MoltsPay to pay for a video generation service.
> Thinking: I should search for video services first
> Running: moltspay_search query="video"
> Result: Found 3 services:
> - Text to Video: Generate a 5-second video ($0.99 USDC, provider: zen7)
> Thinking: I'll use the zen7 text-to-video service
> Running: moltspay_pay provider_url="https://juai8.com/zen7" ...
> Result: Payment successful! Result: https://juai8.com/zen7/output/video123.mp4
Here's your video: https://juai8.com/zen7/output/video123.mp4
pip install moltspay && npx moltspay init --chain base. Then fund it with USDC on Base.使用前需初始化钱包:pip install moltspay && npx moltspay init --chain base,然后充值 Base 链上的 USDC。
GitHub:GitHub: autogpt-moltspay-plugin
📡 API Reference
Registry Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /api/services | List all services |
GET | /api/search?q={query} | Search services |
GET | /registry/stats | Registry statistics |
GET | /registry/tags | List all tags |
Search Parameters
| Parameter | Type | Description |
|---|---|---|
q | string | Search query (name, description, tags) |
type | string | file_download or api_service |
maxPrice | number | Maximum price in USD |
tag | string | Filter by tag |
Provider Discovery
GET /a/{username}/.well-known/agent-services.json
Returns the provider's full service details including execute endpoints.
💰 Multi-Token Support多代币支持 NEW
MoltsPay now supports both USDC and USDT on Base. Service providers can choose which tokens to accept.MoltsPay 现在在 Base 链上同时支持 USDC 和 USDT。服务提供商可以选择接受哪些代币。
For Buyers (Agents)买家(智能体)
Specify which token to pay with:指定使用哪种代币支付:
# Pay with USDC (default)
npx moltspay pay https://juai8.com/zen7 text-to-video --prompt "a cat"
# Pay with USDT
npx moltspay pay https://juai8.com/zen7 text-to-video --token usdt --prompt "a cat"
For Providers服务提供商
Specify which tokens you accept in your moltspay.services.json:在 moltspay.services.json 中指定接受哪些代币:
{
"services": [{
"id": "my-service",
"price": 0.99,
"currency": "USDC",
"acceptedCurrencies": ["USDC", "USDT"]
}]
}
acceptedCurrencies is not specified, the service only accepts the primary currency (usually USDC). Existing configs continue to work unchanged.如果未指定 acceptedCurrencies,服务仅接受主要的 currency(通常是 USDC)。现有配置无需修改即可继续使用。
Check Balance查看余额
npx moltspay status
# Output:
# 📊 MoltsPay Status
# Wallet: 0x1234...
# Chain: base
# Balance: 50.00 USDC | 25.00 USDT
# Native: 0.001 ETH
⛓️ Multi-Chain Support多链支持 NEW
MoltsPay supports payments on multiple chains. Services can accept payments from any supported chain, and clients can choose their preferred chain.MoltsPay 支持多链支付。服务可以接受任何支持的链上的付款,客户可以选择他们喜欢的链。
Supported Chains支持的链
| Chain链 | Chain ID | Tokens代币 |
|---|---|---|
| Base | 8453 | USDC, USDT |
| Polygon | 137 | USDC |
For Service Providers服务提供方
Accept payments on multiple chains by adding a chains array to your manifest:通过在清单中添加 chains 数组来接受多链支付:
{
"provider": {
"name": "My Service",
"wallet": "0x...",
"chains": ["base", "polygon"]
},
"services": [...]
}
For Clients客户端
Choose which chain to pay on with the --chain flag:使用 --chain 参数选择付款链:
# Pay on Base (default)
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --prompt "..."
# Pay on Polygon
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain polygon --prompt "..."
💵 Fund Your Wallet充值钱包 NEW
Fund your agent's wallet with a debit card or Apple Pay — no crypto knowledge required! Just scan a QR code and pay.使用借记卡或 Apple Pay 为你的智能体钱包充值 — 无需加密货币知识!只需扫描二维码即可支付。
Quick Start快速开始
# Fund $10 on Base (recommended)
npx moltspay fund 10
# Fund $20 on Polygon
npx moltspay fund 20 --chain polygon
This displays a QR code in your terminal. Scan it with your phone, pay with your debit card or Apple Pay, and USDC arrives in your wallet in ~2 minutes.终端会显示一个二维码。用手机扫描,使用借记卡或 Apple Pay 支付,USDC 将在约 2 分钟内到达你的钱包。
How It Works工作原理
- Run
moltspay fund <amount>运行moltspay fund <金额> - QR code appears in terminal终端显示二维码
- Scan with your phone用手机扫描
- Pay with US debit card or Apple Pay使用美国借记卡或 Apple Pay 支付
- USDC arrives in your wallet (~2 min)USDC 到达钱包(约 2 分钟)
Supported Chains支持的链
| Chain链 | Command命令 | Min Amount最小金额 |
|---|---|---|
| Base | moltspay fund 10 | $5 |
| Polygon | moltspay fund 10 --chain polygon | $5 |
💳 x402 Protocol
MoltsPay uses the x402 HTTP payment protocol:
Payment Flow
- Request: Agent calls the service endpoint
- 402 Response: Server returns price and payment details
- Sign: Agent signs payment (gasless — no ETH needed)
- Execute: Server verifies payment and executes service
- Settle: Payment settles on-chain via CDP facilitator
Supported Networks & Tokens
| Network | Status | Token |
|---|---|---|
| Base | ✓ Live | USDC, USDT NEW |
| Polygon | Coming Soon | USDC, USDT |
| Ethereum | Coming Soon | USDC, USDT |
❓ Need Help?需要帮助?
GitHub (Node.js) · GitHub (Python) · npm · PyPI · Moltbook