DEV Community

Yaqing2023
Yaqing2023

Posted on

MoltsPay Goes Multi-Chain: Base + Polygon Support for AI Agent Payments

The Problem with Single-Chain AI Payments

When we first built MoltsPay—a payment SDK for AI agents—we started with Base. It made sense: low fees, fast confirmations, and growing adoption in the AI ecosystem.

But developers kept asking: What about Polygon? What about my existing USDC on other chains?

Fair point. If we're building infrastructure for autonomous AI agents, we can't force everyone onto a single chain.

What We Shipped

MoltsPay now supports both Base and Polygon out of the box. Same SDK, same API, just specify your chain:

# Initialize on Base (default)
npx moltspay init --chain base

# Or initialize on Polygon
npx moltspay init --chain polygon
Enter fullscreen mode Exit fullscreen mode

That's it. Your agent wallet works on whichever chain you choose.

Why This Matters for AI Agents

1. User Choice
Your users might already have USDC on Polygon. Now they can pay your AI service without bridging.

2. Cost Optimization
Different chains have different fee profiles. Agents can pick the cheapest option for their use case.

3. Ecosystem Flexibility
Building on an existing Polygon-based platform? No problem. Base-native app? Also covered.

Under the Hood: x402 Protocol

The multi-chain support works seamlessly because of the x402 protocol—HTTP-native payments using the 402 Payment Required status code.

When a client calls your service:

POST /api/generate-video

→ 402 Payment Required
{
  "accepts": [
    { "chain": "base", "token": "USDC", "amount": "0.99" },
    { "chain": "polygon", "token": "USDC", "amount": "0.99" }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The client picks their preferred chain, signs the payment, and retries with the X-Payment header. Server verifies on-chain and fulfills the request.

Zero gas for clients. The x402 facilitator handles all the blockchain complexity.

Try It Out

# Install
npm install moltspay

# Initialize wallet (pick your chain)
npx moltspay init --chain polygon

# Check status
npx moltspay status

# Pay for a service
npx moltspay pay https://example.com/api video-gen --prompt "a sunset over mountains"
Enter fullscreen mode Exit fullscreen mode

Docs: moltspay.com
GitHub: github.com/anthropics/x402

What's Next

We're exploring additional chains based on community demand. Arbitrum and Optimism are on the radar.

If you're building AI agents that need to pay for services (or get paid), give MoltsPay a try. The multi-chain future is here.


Building something cool with MoltsPay? Drop a comment—would love to see what you're working on.

Top comments (0)