DEV Community

Cover image for Multi-Chain Agent Payments with MoltsPay: Base, Polygon, Solana, and Beyond
Zen7
Zen7

Posted on

Multi-Chain Agent Payments with MoltsPay: Base, Polygon, Solana, and Beyond

One API. Seven Chains. Zero Gas for Users.

The Multi-Chain Reality

If you're building AI agents that need to handle payments, you've probably faced this question: which blockchain should I use? Base has low fees. Polygon has adoption. Solana has speed. BNB has the Asian market.

The answer? All of them.

Your agent shouldn't care which chain a user prefers. MoltsPay's Universal Payment Protocol (UPP) abstracts away chain differences, letting you accept payments from any supported network with the same code.

Supported Chains

MoltsPay currently supports seven chains across two virtual machines:

Chain Network VM Native Token Settlement
Base Mainnet/Sepolia EVM ETH CDP Facilitator
Polygon Mainnet/Amoy EVM MATIC CDP Facilitator
BNB Mainnet/Testnet EVM BNB Pre-Approval
Tempo Moderato EVM TEMPO MPP Native
Solana Mainnet/Devnet SVM SOL Pay-for-Success

The key insight: users don't need gas tokens. MoltsPay handles execution costs through various facilitator mechanisms.

How UPP Works

The Universal Payment Protocol normalizes four different underlying protocols:

Client Request
     ↓
   UPP Layer (MoltsPay)
     ↓
┌────┴────┬────┴────┬────┴────┐
│  x402   │   MPP   │  Solana │
│  (EVM)  │ (Tempo) │   PFS   │
└────┬────┴────┬────┴────┬────┘
     ↓         ↓         ↓
   Base     Tempo     Solana
  Polygon            Devnet
   BNB
Enter fullscreen mode Exit fullscreen mode

When a client calls your service, UPP automatically:

  1. Detects the payment chain from the request
  2. Selects the appropriate protocol handler
  3. Verifies payment using chain-specific logic
  4. Settles funds to your wallet

Server Setup (Provider)

Setting up a multi-chain service is straightforward. Create your moltspay.services.json:

{
  "$schema": "https://moltspay.com/schemas/services.json",
  "provider": {
    "name": "My AI Service",
    "wallet": "0xYourEVMWallet",
    "solana_wallet": "YourSolanaWalletAddress"
  },
  "chains": ["base", "polygon", "bnb", "solana", "tempo_moderato"],
  "services": [
    {
      "id": "generate-image",
      "function": "generateImage",
      "price": 0.50,
      "currency": "USDC",
      "description": "Generate an AI image from text prompt"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Notice the two wallet fields:

  • wallet - Your EVM address (works for Base, Polygon, BNB, Tempo)
  • solana_wallet - Your Solana address (optional, for Solana support)

Start your server:

npx moltspay start ./my-service --port 3000
Enter fullscreen mode Exit fullscreen mode

MoltsPay reads your config and exposes the standard /.well-known/agent-services.json endpoint that clients use for service discovery.

Client Setup (Payer)

For clients (agents that pay for services), initialization is chain-agnostic:

# Initialize wallet (supports all chains automatically)
npx moltspay init

# Set spending limits
npx moltspay config --max-per-tx 10 --max-per-day 100

# Check your balances across chains
npx moltspay status
Enter fullscreen mode Exit fullscreen mode

The status command shows balances on all configured chains:

💳 MoltsPay Wallet Status

Address (EVM):    0x1234...5678
Address (Solana): 7xKp...9mNq

Balances:
  Base:     $25.00 USDC
  Polygon:  $10.00 USDC  
  Solana:   $15.00 USDC
  BNB:      $5.00 USDC

Limits:
  Per Transaction: $10.00
  Daily:           $100.00
  Spent Today:     $3.50
Enter fullscreen mode Exit fullscreen mode

Making Multi-Chain Payments

When paying for a service, specify the chain:

# Pay on Base (default)
npx moltspay pay https://service.example/api generate-image \
  --prompt "a sunset over mountains"

# Pay on Polygon
npx moltspay pay https://service.example/api generate-image \
  --chain polygon \
  --prompt "a sunset over mountains"

# Pay on Solana
npx moltspay pay https://service.example/api generate-image \
  --chain solana \
  --prompt "a sunset over mountains"
Enter fullscreen mode Exit fullscreen mode

The service receives the same request regardless of chain. Your handler code doesn't change:

// handlers/generateImage.js
export async function generateImage({ prompt }) {
  const image = await aiModel.generate(prompt);
  return { imageUrl: image.url };
}
Enter fullscreen mode Exit fullscreen mode

MoltsPay verifies payment before your function runs. If payment fails, your code never executes—that's the "pay-for-success" model.

Programmatic Usage

For agents that need to select chains dynamically:

import { MoltsPay } from 'moltspay';

const client = new MoltsPay();

// Discover service and supported chains
const services = await client.discover('https://service.example/api');
console.log('Supported chains:', services.chains);
// ['base', 'polygon', 'bnb', 'solana', 'tempo_moderato']

// Check balances and pick optimal chain
const balances = await client.getBalances();
const preferredChain = selectBestChain(balances, services.chains);

// Execute payment
const result = await client.pay({
  endpoint: 'https://service.example/api',
  service: 'generate-image',
  chain: preferredChain,
  params: { prompt: 'a sunset over mountains' }
});
Enter fullscreen mode Exit fullscreen mode

Chain Selection Strategy

Different chains have different characteristics. Here's a decision matrix:

Priority Recommended Chain Why
Lowest fees Base ~$0.001 per tx
Fastest finality Solana ~400ms
Widest adoption Polygon Most wallets support it
Asian users BNB Popular in APAC region
Native x402 Tempo Built for agent payments

A smart agent might implement adaptive chain selection:

function selectBestChain(balances, supportedChains) {
  // Priority order
  const priority = ['base', 'solana', 'polygon', 'bnb', 'tempo_moderato'];

  for (const chain of priority) {
    if (supportedChains.includes(chain) && balances[chain] >= requiredAmount) {
      return chain;
    }
  }

  throw new Error('Insufficient balance on all chains');
}
Enter fullscreen mode Exit fullscreen mode

Testing on Testnets

Every mainnet chain has a corresponding testnet:

Mainnet Testnet Faucet
Base base_sepolia npx moltspay faucet --chain base_sepolia
Polygon polygon_amoy (Coming soon)
Solana solana_devnet npx moltspay faucet --chain solana_devnet
BNB bnb_testnet npx moltspay faucet --chain bnb_testnet

The MoltsPay faucet dispenses 1 USDC per request (24-hour cooldown per address).

Real-World Example: Zen7 Video Service

Our flagship service, Zen7, accepts payments on multiple chains:

# Check supported chains
curl -s https://juai8.com/zen7/.well-known/agent-services.json | jq .chains
# ["base", "polygon", "bnb", "solana", "tempo_moderato"]

# Generate video (paying on Base)
npx moltspay pay https://juai8.com/zen7 text-to-video \
  --chain base \
  --prompt "a cat dancing on the beach"
Enter fullscreen mode Exit fullscreen mode

Price: $0.99 for text-to-video, $1.49 for image-to-video. Same price regardless of chain.

What's Next

MoltsPay is actively expanding chain support. On the roadmap:

  • Arbitrum - L2 with growing DeFi presence
  • Optimism - Another major L2
  • Avalanche - Fast finality, subnet support

The goal: let agents transact on any chain their users prefer, without changing code.

Getting Started

# Install
npm install -g moltspay

# Initialize multi-chain wallet
npx moltspay init

# Get testnet funds
npx moltspay faucet --chain base_sepolia

# Start accepting payments
npx moltspay start ./your-service --port 3000
Enter fullscreen mode Exit fullscreen mode

Documentation: moltspay.com/docs
Discord: discord.gg/QwCJgVBxVK
GitHub: github.com/Yaqing2023/moltspay


MoltsPay is open-source payment infrastructure for AI agents. One integration, every chain.

Top comments (0)