📚 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
- 💻 Web Client浏览器 SDK — Browser SDK with MetaMask & Phantom浏览器端 SDK,支持 MetaMask 和 Phantom NEW
- 🧪 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, Polygon, Solana, BNB + TempoBase、Polygon、Solana、BNB + Tempo NEW
- 💴 Fiat Payments (Alipay)法币支付(支付宝) — Accept CNY via Alipay通过支付宝收人民币 NEW
- 💚 Fiat Payments (WeChat)法币支付(微信) — Accept CNY via WeChat通过微信收人民币 2.1
- 💰 Balance & Passwordless余额与免密 — Prepaid CNY, no scan after top-up预付人民币,充值后免扫码 2.4
- 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
# 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 "..."
# Pay from a prepaid CNY balance (passwordless — no scan)
npx moltspay pay https://moltspay.com/a/zen7 buy-video --rail balance
# Move funds out (EVM only; needs native gas)
npx moltspay transfer 0xRecipient... 5 --token USDC --chain base
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"
💻 Web Client (Browser SDK)浏览器 SDK NEW
First-class browser support since moltspay@1.6.0 — pay from MetaMask, Phantom, and any EIP-1193 / Solana wallet-adapter wallet. Private keys never enter browser memory; signing is delegated to the injected wallet.从 moltspay@1.6.0 起首次原生支持浏览器 — 可从 MetaMask、Phantom 等任意 EIP-1193 / Solana wallet-adapter 钱包付款。私钥永不进入浏览器内存,签名由注入的钱包代理完成。
moltspay/web ships ESM and works in Vite, Next.js, Webpack, esbuild.
gzip 后 40 KB,纯浏览器构建,不引入任何 Node 专用 API。子路径导出 moltspay/web 提供 ESM,可在 Vite、Next.js、Webpack、esbuild 中直接使用。
Installation安装
npm install moltspay
Quick Start快速开始
import { MoltsPayWebClient, eip1193Signer } from 'moltspay/web'
const client = new MoltsPayWebClient({
signer: eip1193Signer(window.ethereum),
})
const result = await client.pay(
'https://moltspay.com/a/zen7',
'text-to-video',
{ prompt: 'a cat dancing' }
)
Signer Adapters签名适配器
| Adapter适配器 | Wallets钱包 | Chains链 |
|---|---|---|
eip1193Signer(provider) | MetaMask, Rainbow, Frame, any EIP-1193 provider任意 EIP-1193 提供者 | Base, Polygon, BNB, Tempo |
solanaSigner(walletAdapter) | Phantom, Solflare, Backpack, any @solana/wallet-adapter wallet任意 @solana/wallet-adapter 钱包 | Solana |
composeSigners({ evm, svm }) | Combines an EVM signer + Solana signer; routes by chain.组合 EVM + Solana 签名器,按链自动路由。 | All全部 |
api.mainnet-beta.solana.com endpoint returns 403 to browser requests. Pass a per-chain RPC map as solanaRpc: { solana: '…' } pointing to Helius / QuickNode / Alchemy or any RPC that allows CORS from browsers. Add solana_devnet to the same object if you also target devnet (devnet itself has no 403 restriction).
公共 api.mainnet-beta.solana.com 对浏览器请求返回 403。请按链键传入 RPC 映射对象 solanaRpc: { solana: '…' },指向 Helius / QuickNode / Alchemy 或任何允许浏览器 CORS 的 RPC。如同时面向 devnet,可在同一对象内加 solana_devnet 键(devnet 本身没有 403 限制)。
Spending Limits (Optional)消费上限(可选)
Pass a spendingLimits config to record per-browser totals in localStorage and refuse payments that exceed your caps — a safety net for autonomous flows. The client constructs the underlying SpendingLedger internally; you do not instantiate it yourself.在构造时传入 spendingLimits 配置,client 会在 localStorage 中按浏览器记录消费累计值,超出上限的支付将被拒绝 — 用于自动化流程的兜底保护。无需自行 new SpendingLedger,client 会自动构建。
import { MoltsPayWebClient, eip1193Signer } from 'moltspay/web'
const client = new MoltsPayWebClient({
signer: eip1193Signer(window.ethereum),
spendingLimits: {
maxPerTx: 1, // USD per transaction
maxPerDay: 5, // USD per calendar day
},
})
// Throws SpendingLimitExceededError (code: SPENDING_LIMIT_EXCEEDED) when blocked.
Error Classes错误类
Each error has a stable code field — handle by code, not by message.每个错误都有稳定的 code 字段 — 用 code 判断,不要依赖 message 文本。
| Class | code | When触发时机 |
|---|---|---|
NeedsApprovalError | NEEDS_APPROVAL | Token allowance needed (BNB requiresApproval path)需要先授权代币(BNB 的 requiresApproval 路径) |
UnsupportedChainError | UNSUPPORTED_CHAIN | Chain not supported by the current signer setup当前 signer 配置不支持该链 |
PaymentRejectedError | PAYMENT_REJECTED | User declined the wallet prompt用户拒绝了钱包弹窗 |
InsufficientBalanceError | INSUFFICIENT_BALANCE | Wallet balance is below the required amount钱包余额不足 |
SpendingLimitExceededError | SPENDING_LIMIT_EXCEEDED | SpendingLedger blocked the paymentSpendingLedger 拒绝了该支付 |
ServerError | SERVER_ERROR | Provider server returned a non-2xx after settle服务方在结算后返回非 2xx |
MoltsPayError | (base class)(基类) | All other client-side errors所有其他客户端错误 |
Reference Demo参考示例
A complete React + Vite integration showing MetaMask + Phantom + composeSigners lives in the SDK repo:SDK 仓库内有完整的 React + Vite 集成示例,演示 MetaMask + Phantom + composeSigners: examples/web
base, base_sepolia, and solana_devnet. polygon, solana:mainnet, tempo_moderato, bnb, and bnb_testnet are unit-tested only — production usage on those chains is the de-facto verification. See CHANGELOG for the full matrix.
已端到端在浏览器中验证:base、base_sepolia、solana_devnet。其余 5 条链(polygon、solana:mainnet、tempo_moderato、bnb、bnb_testnet)目前仅有单元测试覆盖,首批生产用户即为事实验证。完整 QA 矩阵见 CHANGELOG。
🐍 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", "solana", "bnb", "base_sepolia", "solana_devnet", "bnb_testnet", "tempo_moderato"
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.
Browser-Facing Headers & CORS浏览器侧响应头与 CORS 1.6.0
When serving browser clients (see Web Client), MoltsPayServer auto-advertises CORS headers and accepts the permit settlement scheme. Defaults work out-of-the-box; tighten cors in production.面向浏览器客户端时(参见 Web Client),MoltsPayServer 自动声明 CORS 响应头,并接受 permit 结算方案。默认配置开箱即用,生产环境建议收紧 cors。
| Option / Header选项 / 响应头 | Default默认值 | Purpose用途 |
|---|---|---|
cors (server option)(server 选项) | true (emits *)(响应头为 *) | Accepts boolean (true/false to allow any origin or disable), string[] (origin allow-list), or a CorsOptions object (origins + credentials + maxAge).可为 boolean(true/false 表示允许任意来源或关闭)、string[](来源允许列表),或 CorsOptions 对象(origins + credentials + maxAge)。 |
Access-Control-Expose-Headers | X-Payment-Required, X-Payment-Response, WWW-Authenticate, Payment-Receipt | |
scheme (payment payload)(支付负载) | "exact" | "permit" | Browser flow on Tempo Moderato uses permit (EIP-2612). Node CLI defaults to exact.浏览器在 Tempo Moderato 上使用 permit(EIP-2612);Node CLI 默认使用 exact。 |
import { MoltsPayServer } from 'moltspay'
const server = new MoltsPayServer({
// ...your existing config
cors: ['https://yourapp.com'], // tighten origins in production
})
💰 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 — Mainnet支持的链 — 主网
| Chain链 | Chain ID | VM虚拟机 | Facilitator协调器 | GasGas | Tokens代币 |
|---|---|---|---|---|---|
| Base | 8453 | EVM | CDP | Gasless零 Gas | USDC, USDT |
| Polygon | 137 | EVM | CDP | Gasless零 Gas | USDC |
| Solana | — | SVM | SOL | Server pays (~$0.001)服务端支付(~$0.001) | USDC |
| BNB | 56 | EVM | BNB | Server pays (minimal)服务端支付(极少) | USDC |
Supported Chains — Testnet支持的链 — 测试网
| Chain链 | Chain ID | VM虚拟机 | Facilitator协调器 | GasGas | --chain |
|---|---|---|---|---|---|
| Base Sepolia | 84532 | EVM | CDP | Gasless零 Gas | base_sepolia |
| Solana Devnet | — | SVM | SOL | Server pays服务端支付 | solana_devnet |
| BNB Testnet | 97 | EVM | BNB | Server pays服务端支付 | bnb_testnet |
| Tempo Moderato | 42431 | EVM | Tempo | Native gas-free原生免 Gas | tempo_moderato |
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", "solana", "bnb"]
},
"services": [...]
}
For Clients客户端
Choose which chain to pay on with the --chain flag (Base is the default):使用 --chain 参数选择付款链(默认为 Base):
# 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 "..."
# Pay on Solana
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain solana --prompt "..."
# Pay on BNB
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --chain bnb --prompt "..."
💴 Fiat Payments (Alipay)法币支付(支付宝) NEW
Since v2.0, MoltsPay supports a fiat payment rail via Alipay (支付宝 AI 收), settling in CNY (人民币) alongside the existing USDC crypto rails. It uses the same HTTP 402 flow — a service can price in USDC, CNY, or both. This is a purely additive change: existing crypto-only services keep working unchanged.自 v2.0 起,MoltsPay 在原有 USDC 加密货币轨之外,新增通过 支付宝(支付宝 AI 收) 的法币支付轨,以 人民币(CNY) 结算。它复用同一套 HTTP 402 流程——服务可以用 USDC、CNY 或两者同时定价。该能力为纯新增,既有的仅加密货币服务无需改动、照常运行。
alipay) is a fiat rail, not a blockchain. There is no gas and no on-chain settlement — payment is collected through the Alipay app and settled in CNY. The scheme is alipay-aipay, signed with RSA2.支付宝轨(alipay)是法币轨,不是区块链。没有 Gas、不上链结算——付款通过支付宝 App 收取并以人民币结算。结算方案为 alipay-aipay,使用 RSA2 签名。
Enable the Alipay Rail开启支付宝轨
Add "alipay" to chains, configure provider.alipay with your merchant keys, and add a per-service alipay block with the CNY price. Crypto and fiat can coexist:在 chains 中加入 "alipay",在 provider.alipay 中配置商户密钥,并为每个服务添加带人民币价格的 alipay 配置块。加密货币与法币可并存:
{
"provider": {
"name": "My Service",
"wallet": "0x...",
"chains": ["base", "alipay"],
"alipay": {
"seller_id": "2088xxxxxxxxxxxx",
"app_id": "20210xxxxxxxxxxx",
"seller_name": "My Shop",
"service_id_default": "xxxxxxxx",
"private_key_path": "./keys/app_private_key.pem",
"alipay_public_key_path": "./keys/alipay_public_key.pem"
}
},
"services": [{
"id": "my-service",
"function": "handleRequest",
"price": 0.50,
"currency": "USDC",
"alipay": { "price_cny": "7.00", "goods_name": "My Service" }
}]
}
Configuration Reference配置参考
provider.alipay (required when chains includes alipay)(当 chains 含 alipay 时必填):
| Field字段 | Req必填 | Description说明 |
|---|---|---|
seller_id | ✅ | Merchant Alipay ID (16 digits)商户支付宝 ID(16 位) |
app_id | ✅ | Application ID from the Alipay Open Platform支付宝开放平台的应用 ID |
seller_name | ✅ | Merchant display name商户展示名称 |
service_id_default | ✅ | Default Alipay service_id for this provider该商户默认的支付宝 service_id |
private_key_path | ✅ | Path to your app private key PEM (relative to the manifest)应用私钥 PEM 路径(相对清单文件) |
alipay_public_key_path | ✅ | Path to the Alipay platform public key PEM支付宝平台公钥 PEM 路径 |
gateway_url | — | Open API gateway (default production; use the sandbox URL for testing)开放 API 网关(默认生产;测试用沙箱地址) |
sign_type | — | Signature type (RSA2)签名类型(RSA2) |
services[].alipay (set on each service that accepts CNY)(在每个接受人民币的服务上设置):
| Field字段 | Req必填 | Description说明 |
|---|---|---|
price_cny | ✅ | CNY price as a decimal string in 元, e.g. "7.00" = 7 CNY (NOT cents)人民币价格,以元为单位的小数字符串,如 "7.00" = 7 元(不是分) |
goods_name | ✅ | Goods name shown to the user in the Alipay app在支付宝 App 中向用户展示的商品名称 |
service_id | — | Per-service override (defaults to provider.alipay.service_id_default)单服务覆盖(默认取 provider.alipay.service_id_default) |
CLI ProvisioningCLI 自动安装
The Alipay rail relies on the alipay-bot CLI, which is auto-provisioned on install from the official Alipay CDN (postinstall, best-effort). To skip it (e.g. in CI or crypto-only deployments), set MOLTSPAY_SKIP_CLI_INSTALL=1; to install it manually later, run npx -y @alipay/agent-payment install-cli.支付宝轨依赖 alipay-bot CLI,安装时会自动从支付宝官方 CDN 拉取(postinstall,尽力而为)。如需跳过(如 CI 或仅加密货币部署),设置 MOLTSPAY_SKIP_CLI_INSTALL=1;之后手动安装可运行 npx -y @alipay/agent-payment install-cli。
💚 Fiat Payments (WeChat)法币支付(微信) 2.1+
Since v2.1, MoltsPay adds a second fiat rail via WeChat Pay v3 Native, settling in CNY (人民币). The buyer scans a QR code once in WeChat; the same HTTP 402 flow applies. Crypto, Alipay, and WeChat can all coexist on one service.自 v2.1 起,MoltsPay 新增第二条法币轨——微信支付 v3 Native,以 人民币(CNY) 结算。买家在微信中扫码一次即可付款,复用同一套 HTTP 402 流程。加密货币、支付宝、微信可在同一个服务上并存。
Enable the WeChat Rail开启微信轨
Add "wechat" to chains, configure provider.wechat with your merchant keys, and add a per-service wechat block with the CNY price:在 chains 中加入 "wechat",在 provider.wechat 中配置商户密钥,并为每个服务添加带人民币价格的 wechat 配置块:
{
"provider": {
"name": "My Service",
"chains": ["base", "wechat"],
"wechat": {
"mchid": "1900000000",
"appid": "wxXXXXXXXXXXXXXXXX",
"serial_no": "XXXXXXXXXXXXXXXXXXXXXXXX",
"private_key_path": "./keys/wechat_apiclient_key.pem",
"notify_url": "https://your.host/wechat/notify",
"platform_public_key_path": "./keys/wechat_platform_cert.pem"
}
},
"services": [{
"id": "my-service",
"function": "handleRequest",
"wechat": { "price_cny": "0.07", "goods_name": "My Service" }
}]
}
Configuration Reference配置参考
provider.wechat (required when chains includes wechat)(当 chains 含 wechat 时必填):
| Field字段 | Req必填 | Description说明 |
|---|---|---|
mchid | ✅ | Merchant ID (商户号)商户号 |
appid | ✅ | App ID (official account / mini-program / app)应用 ID(公众号 / 小程序 / App) |
serial_no | ✅ | Merchant API certificate serial number商户 API 证书序列号 |
private_key_path | ✅ | Path to the merchant apiclient_key PEM商户 apiclient_key PEM 路径 |
notify_url | ✅ | Callback URL for async payment notifications异步支付通知回调 URL |
platform_public_key_path | — | WeChat platform certificate PEM. Present ⇒ every order-query response is signature-verified (required to trust the openid identity anchor).微信平台证书 PEM。配置后 ⇒ 每次订单查询响应都会验签(信任 openid 身份锚点的前提)。 |
services[].wechat: price_cny (CNY price in 元, e.g. "0.07"以元为单位的人民币价格,如 "0.07") + goods_name.
💰 Balance Rail & Passwordless余额轨与免密支付 2.2–2.4
The balance rail (balance, v2.2+) is a server-side custodial balance in CNY. The buyer funds it once — via a WeChat top-up pack — and every purchase afterwards deducts from the balance server-side, with no scan and no password (v2.3+). The first purchase against an empty balance still needs one scan, but it buys a pack, not a single item.余额轨(balance,v2.2+)是一个服务端托管的人民币余额。买家只需充值一次——通过微信充值包——之后每次购买都在服务端扣款,免扫码、免密码(v2.3+)。空余额下的首次购买仍需扫码一次,但买的是一个充值包,而非单件商品。
Enable the Balance Rail开启余额轨
{
"provider": {
"chains": ["wechat", "balance"],
"balance": {
"db_path": "./data/balance-cny.sqlite",
"currency": "CNY",
"topup_packs": ["1.00", "5.00", "20.00"],
"auth_mode": "off"
}
}
}
Balance Authentication (auth_mode)余额鉴权(auth_mode)
Each deduction can carry a per-request EIP-191 signature. The account is anchored to the WeChat payer's openid at top-up, and the signer address is TOFU-bound on first signed use. Stage the rollout with provider.balance.auth_mode:每笔扣款可携带一次性的 EIP-191 签名。账户在充值时锚定到微信付款人的 openid,签名者地址在首次签名使用时 TOFU 绑定。用 provider.balance.auth_mode 分阶段上线:
| auth_mode | Behavior行为 |
|---|---|
off | Default. Signature not checked — backward compatible; buyer_id keeps bearer semantics.默认。不校验签名——向后兼容;buyer_id 仍是持有即可用的语义。 |
shadow | Verify signatures and log what would be denied, without blocking. Use to confirm every client signs before tightening.验签并记录「本应拒绝」的请求,但不拦截。用于在收紧前确认所有客户端都已签名。 |
enforce | Reject unsigned / invalid / wrong-signer deductions with 401. Knowing a buyer_id is no longer enough to spend.对未签名 / 无效 / 签名者不符的扣款返回 401。仅知道 buyer_id 不再足以花费余额。 |
openid, but whoever holds the agent key can spend every bound user's balance, so protect <configDir>/balance-identity.key (0600).当前模型是 agent 托管——一把 agent 密钥绑定它充值过的所有账户。账户之间靠 openid 隔离,但持有该 agent 密钥者可花费其名下所有用户的余额,因此请妥善保护 <configDir>/balance-identity.key(0600)。
Client Commands客户端命令
# Identity
npx moltspay balance whoami [server] # local signer address / bound identity
npx moltspay balance bind <server> # bind signer to a balance account
# Recoverable top-up (for turn-based chat agents)
npx moltspay balance topup-order # mint a WeChat top-up pack (QR), returns immediately
npx moltspay balance topup-confirm <out_trade_no> # confirm + credit later (idempotent)
npx moltspay balance topup-status # inspect a pending order
npx moltspay balance topup-list # list pending orders
💵 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 the chain's facilitator (CDP for Base/Polygon; self-hosted for Solana/BNB/Tempo)
Supported Networks & Tokens
| Network | Status | Token |
|---|---|---|
| Base | ✓ Live | USDC, USDT NEW |
| Polygon | ✓ Live | USDC |
| Solana | ✓ Live | USDC |
| BNB | ✓ Live | USDC |
| Base Sepolia (testnet) | ✓ Live | USDC |
| Solana Devnet (testnet) | ✓ Live | USDC |
| BNB Testnet (testnet) | ✓ Live | USDC |
| Tempo Moderato (testnet) | ✓ Live | USDC |
❓ Need Help?需要帮助?
GitHub (Node.js) · GitHub (Python) · npm · PyPI · Moltbook