Kx402

io.github.Kali123411由 GitHub 账号 Kali123411 发布v0.1.1更新于 Oct 24, 2026

Kaspa x402 agent payer — pay x402 v2 services on Kaspa (KAS) per call, no account or API key

已验证STDIO仅桌面金融AI 与机器学习

概览

AI 生成的概览

让助手用本地钱包按次支付 Kaspa L1 上的 x402 v2 服务,无需账号或 API 密钥。

可以做什么
  • 查看钱包地址与可用 KAS 余额
  • 在不付款的情况下查看 402 报价,了解价格与收款方
  • 支付 x402 报价并返回结果与结算信息
  • 将每笔付款限制在该报价自身的收款方与价格内,并受最高金额约束
适用场景
当助手需要调用 Kaspa 上按次付费的 x402 服务,并希望自行以小额完成结算、无需注册或绑定银行卡时使用。建议先在 testnet-10 上试用,再切换到主网。
运行要求
通过 npx 以 stdio 在本地运行(需要 Node.js)。需要将 rusty-kaspa v2.0.0 nodejs WASM SDK 的路径填入 KASPA_X402_KASPA_WASM_MODULE,并在 KASPA_X402_FUNDING_WALLET 中提供资金密钥(wallet-key 文件路径或原始 64 位十六进制密钥);可选 KASPA_X402_NETWORK(默认 testnet-10)与 KASPA_X402_RPC_URL。钱包需先充值 KAS,并需要网络访问。
安装前请注意
支付工具会动用钱包中的真实资金,README 称项目处于 alpha 阶段并建议先使用 testnet-10。KASPA_X402_FUNDING_WALLET 保存的是私钥,应放在权限为 0600 的文件中且不要提交到 git。付款会发送给第三方服务并在链上广播;请用 max_sompi 限制支出,并尽量先做试运行。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Kx402,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

kx402 — Kaspa x402 agent payer

An agent-centric payer for x402 services settled on Kaspa L1. One package, three surfaces over the same proven payment core:

  • SDK — import { openWallet, payExact } from "kx402" to pay x402 offers from your own code.
  • CLI — kx402 offer|pay|balance|addr for humans and scripts.
  • MCP server — drop kx402-mcp into an agent (Claude, etc.) so it can pay Kaspa x402 services as a tool.

It speaks the x402 v2 exact / standard-native flow against the @kaspa-x402 binding — conforming to the standard wire format, not extending it. It's the demand side of the Kaspa·402 marketplace.

⚠️ Alpha, and pay spends real funds. Use testnet-10 first. Keep funding keys in 0600 files, never in git.

What it solves

The internet's payment plumbing assumes a person is buying: you sign up, get an API key, put a card on file, click "approve." An AI agent can't do any of that — and you don't want to hand it your credit card. So agents can reason and act, but the moment a task needs a paid tool (data, compute, a model, an API), a human has to set up the billing first.

kx402 closes that gap. It gives an agent a wallet it can actually operate, and lets it pay per use on its own:

  • No account, no API key, no signup. The agent pays the exact price for each call on the spot; it needs no relationship with the service.
  • Micropayments cards can't do. Credit cards have a ~30¢ floor. Settling in KAS on Kaspa makes fractions-of-a-cent, per-call payments practical.
  • A wallet built for software, not fingers. It builds, signs, sends, and proves a payment programmatically in about a second, with no human in the loop.
  • Guardrails so it can't run wild. Every payment is capped at the offer's own price, paid only to that service, up to a limit you set — autonomy without the risk of overspending or paying the wrong party.

Think of it as a prepaid card with strict rules baked in: the agent can buy the specific things it needs, in tiny amounts, whenever it needs them, but it physically can't overspend or pay a stranger.

Install

bash
npm install -g kx402      # or: npm install kx402  (for SDK use)npm run fetch-sdk         # downloads the rusty-kaspa v2.0.0 WASM SDK into ./vendor

Kaspa signing needs the official rusty-kaspa v2.0.0 nodejs WASM SDK — npm's kaspa-wasm is a different/stale ABI and fails with "memory access out of bounds". npm run fetch-sdk grabs the right one; then point KASPA_X402_KASPA_WASM_MODULE at the printed kaspa.js path.

Configure

Copy .env.example to .env and fill it in (or pass any of these as flags / env vars):

VariableMeaning
KASPA_X402_KASPA_WASM_MODULEPath to the v2.0.0 nodejs WASM SDK kaspa.js
KASPA_X402_FUNDING_WALLETwallet-key:/path/to/wallet.key or a raw 64-hex key
KASPA_X402_NETWORKkaspa:mainnet or kaspa:testnet-10 (default)
KASPA_X402_RPC_URLOptional; a public PNN node is resolved automatically if unset

CLI

bash
kx402 addr    --config-file .env                 # show the wallet address (fund it first)kx402 balance --config-file .env                 # spendable KASkx402 offer  https://host/exact --config-file .env   # inspect a 402 offer (no payment)kx402 pay    https://host/exact --prompt "hi" --config-file .env   # pay and print the result

Input rides in the query on an exact GET — use --text / --prompt / --model / --input as the resource expects. Safety flags: --max <sompi> caps the spend; --dry builds the signed tx without broadcasting.

SDK

js
import { openWallet, payExact, resolveWalletConfig } from "kx402";
const wallet = await openWallet(resolveWalletConfig());   // reads env / .envconst r = await payExact(wallet, "https://host/exact?prompt=hello");console.log(r.status, r.body, r.settlement);await wallet.close();

Every payment is bounded by a fundingPolicy derived from the offer itself — it will only pay the offer's payTo, at its profile, up to your max.

MCP server

Run kx402 mcp (or the kx402-mcp bin) — a stdio server exposing kaspa_x402_address, kaspa_x402_balance, kaspa_x402_offer, and kaspa_x402_pay (which spends real funds, bounded by max_sompi). Example client config:

json
{  "mcpServers": {    "kx402": {      "command": "npx",      "args": ["-y", "kx402", "mcp"],      "env": {        "KASPA_X402_KASPA_WASM_MODULE": "/abs/path/vendor/kaspa-wasm32-sdk/nodejs/kaspa/kaspa.js",        "KASPA_X402_FUNDING_WALLET": "wallet-key:/abs/path/wallet.key",        "KASPA_X402_NETWORK": "kaspa:testnet-10"      }    }  }}

How it settles

On mainnet, kx402 uses non-hosted settlement: it broadcasts the signed tx itself, waits for acceptance on the same REST indexer the gateway verifies against, then presents the PAYMENT-SIGNATURE — so the gateway settles by observing the accepted tx and never needs to broadcast. All within the standard x402 v2 lifecycle.

Related

  • @kaspa-x402 — the Kaspa x402 binding this builds on.
  • kaspa-402.org — the marketplace of x402-payable services on Kaspa.

License

MIT

来源:README.md,提交 42d0746

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分