区块链验证服务器

W3Ledger MCP Server是一个为AI代理提供区块链交易验证和管理的服务器,支持余额查询、礼品卡创建与领取、赞助卡创建与领取以及双签名购买处理。

  • by baskcart
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 baskcart/w3ledger-mcp-server

使用说明

W3Ledger MCP服务器

AI代理的自我验证账本——每笔交易都经过加密签名和链式链接。

W3Ledger(Rolledge)是一个MCP(模型上下文协议)服务器,它使AI代理能够检查令牌余额、创建和申领礼品卡、创建和领取赞助商卡以及处理双重签名的购买——所有这些都由加密签名保护。

每次写入操作都需要 双重签名 (发送者+接收者/分发)。服务器端的Lambda函数验证所有签名并强制执行链连续性。MCP服务器是一个瘦HTTP客户端,它不能绕过安全。


⚡ 快速开始

通过npx安装(推荐)

无需安装——只需配置您的AI客户端:

克劳德桌面版 (claude_desktop_config.json):

{
  "mcpServers": {
    "w3ledger": {
      "command": "npx",
      "args": ["-y", "w3ledger-mcp-server"]
    }
  }
}

光标 (.cursor/mcp.json):

{
  "mcpServers": {
    "w3ledger": {
      "command": "npx",
      "args": ["-y", "w3ledger-mcp-server"]
    }
  }
}

VS Code (.vscode/mcp.json):

{
  "servers": {
    "w3ledger": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "w3ledger-mcp-server"]
    }
  }
}

先决条件

  • Node.js 18+
  • 不需要外部数据库或云凭据-服务器连接到W3Ledger API

🛠️ 工具(共6个)

🟢 阅读(安全)

工具 说明
check_balance 检查公钥的DAH、DAHYM、DAHLOR和W3SH令牌余额。包括忠诚度等级(种子→ Joist)的现金返还率。

🟡 书写(需要双重签名)

工具 说明
create_gift_card 通过借记客户的DAH余额创建礼品卡。需要客户签名+分销联合签名。
claim_gift_card 申领已发行的礼品卡,并记入申领者的DAH余额。
create_sponsor_card 使用GPS坐标创建基于位置的赞助商卡。需要双重签名。
claim_sponsor_card 在赞助商所在地附近领取已发放的赞助商卡。
purchase_product 通过借记发送方和贷记接收方(商家)购买产品。需要发送方+接收方双重签名。

❌ 排除(故意)

工具 原因
fund_account 使用服务器端分发密钥。对MCP来说太危险了——可能会记入任意账户。

🔐 安全模型

W3Ledger实现了 自我验证链 --每笔交易都与前一笔交易进行了加密链接:

┌──────────────────────────────────────────────────────────┐
│  AI Agent (Claude / Cursor / VS Code)                    │
│  "Purchase a VR session for 35 DAH"                      │
└──────────────────┬───────────────────────────────────────┘
                   │ MCP Protocol (stdio)
┌──────────────────▼───────────────────────────────────────┐
│  W3Ledger MCP Server (thin HTTP client)                  │
│  • Forwards tool calls to API Gateway                    │
│  • Does NOT verify signatures (server does)              │
│  • Does NOT access database directly                     │
│  • Equivalent security to curl                           │
└──────────────────┬───────────────────────────────────────┘
                   │ HTTPS
┌──────────────────▼───────────────────────────────────────┐
│  API Gateway → Lambda Functions (server-side)            │
│                                                          │
│  ✅ Validates both signatures (sender + receiver)        │
│  ✅ Verifies chain continuity (prev_balance linkage)     │
│  ✅ Verifies previous transaction's signature            │
│  ✅ Checks balance sufficiency                           │
│  ✅ Enforces timestamp window (5 min)                    │
│  ✅ Atomic DynamoDB transactWrite (all-or-nothing)       │
└──────────────────────────────────────────────────────────┘

支持的签名方案

方案 用例
EVM(秒256k1) 以太坊/MetaMask钱包(personal_sign)
Ed25519(曲线25519) Solana、Cardano、Stellar、NEAR、Algorand、Aptos、Cosmos、TON钱包
ML-DSA-65 后量子签名(NIST标准)
SLH-DSA 基于无状态哈希的后量子签名

⚙️ 配置

环境变量

变量 必填 默认 描述
ROLLEDGE_API_URL 否 W3Ledger API Rolledge API网关的基本URL
ROLLEDGE_API_KEY 无 - 用于身份验证访问的可选API密钥
MCP_LOG_LEVEL 没有 info 日志记录级别: debug, info, warn, error

验证安装

列出所有可用工具:

npx w3ledger-mcp-server --list-tools

💡 对话示例

You:    "Check my balance"
Claude: [calls check_balance with your public key]
        "Your DAH balance is 1,250.00
         W3SH: 520 (Kindling tier — 10% cashback)
         DAHLOR: 0  |  DAHYM: 0"

You:    "Send a 100 DAH gift card to my friend for coffee"
Claude: [calls create_gift_card — requires your signature]
        "Please sign this transaction with your wallet..."
        [after dual signing]
        "Gift card GC-x8k2 created! Value: 100 DAH
         Your new balance: 1,150.00 DAH"

You:    "Buy a VR session for 35 DAH"
Claude: [calls purchase_product — requires sender + receiver signatures]
        "Transaction confirmed! Order #VR-2026-001
         Spent: 35 DAH  |  New balance: 1,115.00 DAH
         🏅 Cashback: 3.50 W3SH earned (Kindling tier, 10%)"

🏆 W3SH忠诚度等级

根据您的等级,购买会自动获得W3SH现金返还:

级别 要求W3SH 现金返还率
🌱 种子 0 0%
🌿 嫩枝 100 5%
🔥 引火柴 500 10%
🪵 日志 2,000 15%
🏗️ 托梁 10,000 20%

🔗 链接


📄 许可证

麻省理工学院——见 许可证