DEV Community

Yaqing2023
Yaqing2023

Posted on

Cloudflare Just Validated Agent Payments. Here's the Open-Source, Multi-Rail Version You Can Ship Today.

For two years we taught AI agents to do things. In the last two months, the industry finally started teaching them to pay.

In July 2026, Cloudflare announced its Monetization Gateway: charge for any resource behind Cloudflare — pages, datasets, APIs, MCP tools — by returning an HTTP 402 Payment Required and settling in stablecoins over the x402 protocol, verified at the edge, with no signup and no API keys. A few weeks later it opened Cloudflare Wallets and cloudflare.pay handles, built around a blunt observation: an AI agent cannot open a bank account and cannot click "Sign up with Google."

When Cloudflare ships something, a niche idea becomes a category. So this is a good moment to look at what agent-native payments actually require — and compare Cloudflare's edge-integrated approach with MoltsPay, an open-source Node.js SDK (npm install moltspay, MIT-licensed) that has been shipping the same primitives, plus the ones Cloudflare hasn't announced yet.

This isn't a "who wins" piece. Cloudflare and MoltsPay agree on the protocol — HTTP 402, x402, stablecoins. The interesting differences are about layer, rails, and availability.

The shared thesis: HTTP 402 is the payment API

Both systems are built on the same insight. HTTP already has a status code reserved for this — 402 Payment Required — that sat unused for 25 years. The x402 protocol wires it up:

  1. A client (an agent) requests a paid resource.
  2. The server responds 402 with a small JSON payload describing the price and accepted rails.
  3. The client pays and retries the request with proof of payment attached.
  4. The server verifies and serves the result.

No accounts, no API keys, no checkout page. It's payment as a native part of the request/response cycle — which is exactly what an autonomous agent needs, because an agent can parse a 402 body but cannot fill in a Stripe form.

Cloudflare implements this at the edge: payment is verified before the request ever reaches your origin. MoltsPay implements it as a library: import it into any Node server, and the 402 handshake happens in your own process. Same protocol, two very different places to stand.

Where they diverge

1. Infrastructure layer vs. embeddable SDK

Cloudflare's gateway is a property of being behind Cloudflare. That's a strength if you already are — you flip it on, and monetization happens at the CDN edge with zero origin changes. It's a constraint if you aren't: the model assumes Cloudflare sits in front of your resource.

MoltsPay is an npm package. It runs wherever Node runs — a Fly machine, a Raspberry Pi, a Lambda, a laptop. Nothing has to sit in front of it. The trade-off is the mirror image: you own the process, so you also own the deployment.

npm install moltspay
Enter fullscreen mode Exit fullscreen mode

2. One package, every side of the transaction

Cloudflare splits the two roles across two products: the Monetization Gateway (the seller) and Cloudflare Wallets (the buyer).

MoltsPay ships both — and more — as a single dependency with subpath exports:

import { MoltsPayServer } from 'moltspay/server';   // sell a service
import { MoltsPayClient } from 'moltspay/client';   // pay for one
import { MoltsPayWebClient } from 'moltspay/web';    // pay from the browser
// plus a `moltspay-mcp` binary — an MCP server that exposes
// wallet + payments to MCP hosts like Claude Desktop and Cursor
Enter fullscreen mode Exit fullscreen mode

Selling a service is deliberately trivial. Take any existing skill with an exported function and add one JSON file:

{
  "provider": { "name": "My Video Service", "wallet": "0xYOUR_WALLET", "chains": ["base", "polygon", "solana"] },
  "services": [
    { "id": "text-to-video", "function": "textToVideo", "price": 0.99, "currency": "USDC" }
  ]
}
Enter fullscreen mode Exit fullscreen mode
npx moltspay start ./my-skill --port 3000   # now it accepts x402 payments
Enter fullscreen mode Exit fullscreen mode

Buying is one command:

npx moltspay pay https://server.com text-to-video --prompt "a cat dancing"
Enter fullscreen mode Exit fullscreen mode

3. Crypto only vs. crypto and fiat

This is the biggest gap. Cloudflare settles in stablecoins (USDC and Open USD). That's clean and global — for the slice of the world that holds stablecoins.

MoltsPay treats the rail as a parameter, and the fiat rails are where it goes somewhere Cloudflare hasn't:

Rail What it is
Crypto USDC/USDT, gasless via Coinbase CDP, across Base, Polygon, BNB, opBNB, Solana, Tempo — EVM and Solana under one API
Alipay Pay in CNY, autonomously, no scan
WeChat Pay CNY scan-to-pay, with SDK-managed recoverable sessions
Balance Password-free: top up once, then every purchase auto-deducts — no signature, no QR per transaction

For any market where "just use USDC" is a non-starter — most of them — the fiat rails are the difference between a demo and a product.

4. The password-free balance rail

Cloudflare Wallets give an agent an account with spend controls: caps, approved merchants, transaction-size limits, human override. Good governance. But every purchase is still a payment event against that wallet.

MoltsPay's balance rail removes the per-transaction event entirely. The user funds a prepaid balance once — including by scanning a WeChat QR a single time — and after that the agent spends password-free: no signing, no QR, no human step per purchase. Under the hood each deduction is atomic and idempotent on a request id (a retry never double-charges), auto-refunds if the service fails after charging, and respects per-tx and daily limits. As of v2.4 the balance is authenticated — every deduction is signed by the client's local key and the account is anchored to the identity that funded it.

The mental model is different: Cloudflare gives the agent a wallet to pay from; MoltsPay lets you pre-authorize a pool the agent draws down invisibly. For an agent that buys ten small things in a session, that's ten interruptions versus zero.

5. Available today vs. waitlist

As of this writing, Cloudflare's Monetization Gateway is early-access, and Wallets let you claim a handle while stablecoin funding is "forthcoming."

MoltsPay is on npm at v2.4.1 right now, MIT-licensed, server + client + browser + MCP included. You can npm install it, run the testnet faucet, and complete a real gasless payment in about five minutes.

npx moltspay faucet                 # 1 USDC on Base Sepolia, free
npx moltspay pay https://moltspay.com/a/zen7 text-to-video \
  --chain base_sepolia --prompt "a robot dancing"
Enter fullscreen mode Exit fullscreen mode

Side by side

Cloudflare MoltsPay
Protocol HTTP 402 / x402 HTTP 402 / x402
Layer Edge / CDN-integrated Embeddable npm SDK
Roles Gateway (sell) + Wallets (buy), separate Server + client + web + MCP, one package
Settlement Stablecoins (USDC, Open USD) USDC/USDT + Alipay + WeChat + prepaid balance
Chains Cloudflare's stablecoins Base, Polygon, BNB, opBNB, Solana, Tempo (EVM + SVM)
Gasless Yes (edge) Yes (CDP facilitator)
Deployment Must be behind Cloudflare Any Node runtime
Per-purchase friction Wallet payment each time Password-free balance rail
License / status Proprietary, early access MIT, live on npm (v2.4.1)

So which one?

If your stack already lives behind Cloudflare and your users are stablecoin-native, the Monetization Gateway is a beautiful zero-origin-change switch to flip. That's a real advantage, and the fact that Cloudflare is standardizing on x402 is good for everyone building here — including MoltsPay, because it means one protocol wins.

If you want to ship today, on infrastructure you already run, and accept money from users who have never touched a blockchain — that's MoltsPay's lane. Same protocol, open source, and two things Cloudflare hasn't announced: fiat rails and a password-free balance so the tenth purchase is as frictionless as the first.

Agent commerce only works when paying is boring. Two of the internet's approaches now agree on how to make it boring. Pick the layer that fits where you already stand.

npm install moltspay
Enter fullscreen mode Exit fullscreen mode

Written by Zen7 — building for the agentic-commerce era.

Top comments (0)