
x402 Ethereum RPC
io.github.ffboers由 GitHub 帳號 ffboers 發布v1.0.0更新於 Oct 24, 2026
Ethereum mainnet JSON-RPC paid per call in USDC on Base. No account, no API key: the wallet pays.
概覽
讓助理呼叫以太坊主網 JSON-RPC 方法,按次以 Base 上的 USDC 從錢包付款,不需要 API 金鑰。
- 可以做什麼
- 這是一個本機 MCP 伺服器,把付費的以太坊 JSON-RPC 閘道當成工具暴露出來,助理可以查詢主網資料,例如區塊高度、日誌與狀態。每次呼叫依方法實際耗費的工作量定價,付款由錢包簽署授權,以 Base 上的 USDC 結算。閘道在收費前拒絕的請求,或節點本身拒絕的請求,會以錯誤回傳而不計費。原始交易可經由公開端點轉送,而不走營運方自己的節點。
- 適用情境
- 適合助理需要以太坊主網 RPC 存取、但不想註冊帳號或管理 API 金鑰的情境,也適合能接受用錢包按次付費的情況。它也可以當成主要 RPC 端點後方的付費備援,因為未使用的備援不會產生費用。
- 執行需求
- 以本機程序在使用者機器上執行(僅限桌面端)。需要支援 x402 的用戶端,以及一個已儲值、能在 Base 上簽署 USDC 授權的錢包,並需要連線到閘道端點的網路。未宣告需要帳號或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 x402 Ethereum RPC,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
x402-rpc-gateway
A Cloudflare Worker that sells JSON-RPC access to your own Ethereum node, one request at a time, over x402. No accounts, no API keys, no invoices: a caller signs a USDC authorization on Base and gets the answer in the same exchange.
Running in production at 402rpc.com.
Why this exists
Selling RPC access normally means building signup, billing, key rotation and rate plans before you serve a single request. x402 removes all of it — but a naive gateway that simply charges per call creates two new problems, and this template solves both.
Callers must never pay for an answer you cannot give. Every request is checked before the paywall. A blocked namespace, a block below your history floor, a log range that is too wide — all return HTTP 400, and x402 does not settle on a response of 400 or higher. Node failures return 502 for the same reason.
Flat pricing loses money. eth_getLogs across ten thousand blocks costs your node
hundreds of times more than eth_blockNumber. Prices here scale with the work a method
actually costs.
Your node's own refusals arrive as HTTP 200. A node that says "no state available
at that block" or "too many logs in one response" returns a JSON-RPC error with a 200
status — and x402 settles on a 200. Left alone, your customers pay for answers you
could not give. This template translates that class of error into a 4xx so nothing
settles. Errors that are a real answer, execution reverted for instance, stay
chargeable.
What you get
- Per-method pricing, configurable, with a ceiling so a batch never surprises anyone
- A policy layer that refuses before charging, with reasons a caller can act on
- Raw transactions relayed through public RPCs instead of your own node — see Privacy
- Discovery metadata so agents can find and use the service without a human
- A landing page for humans and JSON for machines, chosen by the
Acceptheader - An MCP server, so any agent can use it as a tool
- A fallback example: one line to add your gateway as a paid standby behind a primary
Setup
At minimum, set PAY_TO_ADDRESS, ORIGIN_URL and PUBLIC_URL. Everything else has
a working default.
For a mainnet network you need Coinbase CDP credentials — the public x402.org facilitator serves testnets only:
Without them the Worker deliberately answers 503 rather than issuing payment challenges it cannot settle.
Three things the documentation will not tell you
The facilitator has an undocumented floor. Amounts around $0.0002 are rejected with
amount_too_low; $0.001 goes through. Price differentiation therefore only works
upward from roughly a tenth of a cent.
The Bazaar only indexes x402 version 2. Every one of the twenty resources I
checked runs v2; none run v1. If you build on the v1 packages (x402-hono,
x402-fetch — last published April 2026) your service works but is invisible to the
discovery layer agents actually query. This template uses v2 throughout.
Pin resource to your public URL. Left to derive it from the request, the
middleware puts your Worker's internal hostname — which contains your Cloudflare
account name — into every payment challenge, right next to your receiving address.
Verify your own claims
Everything this template puts in your payment terms and landing page is a promise to a paying stranger. Test them against what your node actually does, not against what you believe it does. Three that bit us:
- "History from block N onward" — check block N and N-1.
- "Historical state calls are refused, not charged" — a node's own refusal arrives as
HTTP 200, so without translation it settles. See
nodeRefusalinpolicy.ts. - "eth_getLogs up to N blocks" — your client has its own cap on logs per response (Nethermind defaults to 20,000), which bites long before your block limit does.
Getting found
Ranking in the Bazaar is driven by measured usage — l30DaysTotalCalls and
l30DaysUniquePayers — not by how well you write your description. Worth knowing
before you spend an afternoon on copy.
Worth knowing too: as of August 2026 the entire visible Bazaar handled roughly 1,200 paid calls in thirty days across eighty services. The busiest Ethereum RPC among them served fourteen. Build for the market this becomes, not the one it is.
What this template does for you anyway: a bazaar discovery extension so you are
indexed at all, an iconUrl, and payment accepted on Base, Polygon and Arbitrum so
more wallets can reach you. What it deliberately does not do is inflate your own call
count — that buys a position in a list nobody reads yet, with your own money.
Protecting your origin
Set ORIGIN_TOKEN as a secret and have your origin require the matching
X-Origin-Token header. Without it, anyone who learns your origin hostname uses your
node for free and the paywall is decorative. A minimal reference proxy is in
examples/origin-proxy.py.
Privacy
The receiving address is necessarily public: it is in every payment challenge. Your node's IP is also public, because it takes part in the peer-to-peer network. The link between the two is what you protect.
Someone who submits a transaction through your gateway and watches which IP broadcasts
it first learns where your service physically runs. Setting RELAY_URLS sends raw
transactions out through public endpoints instead, and that trail disappears. Every
other method only returns answers and reveals nothing.
Client usage
Any x402 client pays and retries automatically:
As a paid fallback behind your own node — see examples/fallback.mjs:
A standby you never use costs nothing. That is the property a subscription cannot offer, and it is the strongest reason to run one of these.
Licence
MIT.
來源:README.md,提交 f2adb27
工具
0版本歷史
1- v1.0.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分