📚 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发布你的服务
- SDK & CLISDK 和 CLI — Node.js & PythonNode.js 和 Python
- 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所有接口
- 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"
}]
}
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📦 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
npx moltspay pay https://moltspay.com/a/zen7 text-to-video --prompt "..."
For Service Providers服务提供方
# Validate your service config
npx moltspay validate ./my-skill
# Start accepting payments
npx moltspay start ./my-skill --port 3000
🦜 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"]
}
},
"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.
💳 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
| Network | Status | Token |
|---|---|---|
| Base | ✓ Live | USDC |
| Polygon | Coming Soon | USDC |
| Ethereum | Coming Soon | USDC |
❓ Need Help?需要帮助?
GitHub (Node.js) · GitHub (Python) · npm · PyPI · Moltbook