内容
# anchor-x402
> 为 AI 代理提供十六种付费服务 — 九种通用基础服务,一种由代理驱动的钱包调查工具,五种通用 LLM 端点(roast, oracle, tldr, aura, grade),以及一个有签名的链上 RNG(roll)。此外,为没有自己代理的用户提供一个托管代理聊天机器人,网址为 [chat.anchor-x402.com](https://chat.anchor-x402.com)。一个 AWS Lambda,一个 OpenAPI 规范,跨十二多个代理发现表面进行索引([CDP Bazaar](https://docs.cdp.coinbase.com/x402/bazaar),[agentic.market](https://agentic.market),[x402scan](https://www.x402scan.com),[PayAPI Market](https://payapi.market),[Poncho](https://tryponcho.com),[MCP Registry](https://registry.modelcontextprotocol.io),[Glama](https://glama.ai) — 见 [列表](#列表)。按调用次数支付 **USDC on Base 或 Solana**,或 **JPYC on Polygon**(¥1 per anchor call)— 无需 API 密钥,无需账户,无需订阅。
**网站:** https://anchor-x402.com
**信任门户:** https://anchor-x402.com/trust/
**实时 API:** `https://api.anchor-x402.com`
**状态:** https://anchor-x402.betteruptime.com
**MCP 服务器:** [`anchor-x402-mcp`](https://www.npmjs.com/package/anchor-x402-mcp) on npm — `npx anchor-x402-mcp` 将所有 14 种工具连接到 Claude Desktop / Cursor / Continue
**Swagger UI:** [/docs](https://api.anchor-x402.com/docs)
**OpenAPI:** [/openapi.json](https://api.anchor-x402.com/openapi.json)
## 服务
| 端点 | 方法 | 价格 | 目的 |
|---|---|---|---|
| `/v1/anchor` | POST | $0.005 | 将 32 字节哈希锚定到 Base + Solana 主网 |
| `/v1/screen` | GET | $0.001 | 对任何钱包地址进行制裁 + AML 筛查 |
| `/v1/attest` | POST | $0.010 | 验证钱包签名,双链锚定结果 |
| `/v1/decode/tx` | POST | $0.001 | 结构化解码任意主网交易(Base / Ethereum / Solana) |
| `/v1/resolve/name` | GET | $0.001 | 跨链名称解析(ENS,Bonfida SNS) |
| `/v1/price/token` | GET | $0.001 | 按符号或链 + 合约获取 USD 现货价格 |
| `/v1/decode/calldata` | POST | $0.001 | EVM 调用数据的 4 字节选择器 + ABI 参数解码 |
| `/v1/parse/datetime` | POST | $0.001 | 自由格式日期时间字符串 → 结构化 ISO 8601 |
| `/v1/intel/wallet` | GET | $0.005 | 捆绑钱包情报:余额 + 活动 + 身份 + 制裁 |
| `/v1/investigate` | POST | $1.77 | 代理驱动的钱包尽职调查 — 异步,签名报告 + JSON 边车,双链锚定 |
| `/v1/roast` | POST | $0.050 | 目标的 LLM 烤 |
| `/v1/oracle` | POST | $0.050 | 对问题的 yes/no 裁决,双链锚定 |
| `/v1/tldr` | POST | $0.010 | 总结 URL 或文本块 |
| `/v1/aura` | POST | $0.010 | Aura/vibe 层级评分 |
| `/v1/grade` | POST | $0.010 | 对文本的评分反馈 |
| `/v1/roll` | POST | $0.001 | 签名可验证 RNG(骰子/范围滚动) |
所有端点接受 **Base** 或 **Solana** 主网的 USDC 支付,并且当配置了 Polygon 金库时,接受 **Polygon** 上的 **JPYC** 支付(日本首个 FSA 许可的 yen 稳定币,通过正在进行的 EIP-3009 促进者结算;`/v1/anchor` 在此轨道上定价为 ¥1 per call)。所有返回 `v2 PaymentRequired` 带有 `extensions.bazaar`,因此它们在结算时由 CDP 促进者自动索引。
## 为什么
该仓库中有两个产品论点:
1. **信任基础设施**(`anchor`,`attest`,`screen`,`intel-wallet`)— 代理支付加密的,多链的,签名的收据,证明 AI 的决策按照声称的方式进行。除此之外,代理 API 经济中没有其他提供此原语的服务。
2. **通用工具**(`decode/tx`,`resolve/name`,`price/token`,`decode/calldata`,`parse/datetime`)— 代理支付亚分价格跳过编排代码,缓存未命中和速率限制的免费 API。每个调用替换 2–10 行样板代码。
3. **LLM + 签名 RNG**(`investigate`,`roast`,`oracle`,`tldr`,`aura`,`grade`,`roll`)— 高级代理驱动的尽职调查,通用文本端点和可验证的链上随机性,按调用次数付费,无需 LLM 密钥或 RNG 神谕。
## 快速入门(操作员)
```bash
# 1. 在 venv 中安装依赖
make install
# 2. 配置( treasury keys,CDP 凭证 — 见 .env.example)
cp .env.example .env
$EDITOR .env
# 3. 本地开发(无实际锚点 — 仅导入烟雾测试)
make local
# 4. 部署到 AWS
make build && make deploy-guided
# 5. 端到端付费测试(总共花费约 $0.026 USDC)
.venv/bin/python scripts/test_e2e.py
# 6. 测试单个服务
.venv/bin/python scripts/test_e2e.py --only anchor
```
## 快速入门(代理 / 消费者)
如果你是 AI 代理(或正在构建一个)使用 [x402 客户端 SDK](https://github.com/coinbase/x402):
```python
from x402 import x402ClientSync
from x402.mechanisms.evm.exact import ExactEvmClientScheme
from x402.mechanisms.evm.signers import EthAccountSigner
from x402.http.clients.requests import x402_requests
from eth_account import Account
cli = x402ClientSync()
cli.register("eip155:8453", ExactEvmClientScheme(signer=EthAccountSigner(Account.from_key("0xYOUR_KEY"))))
session = x402_requests(cli)
# 锚定任意哈希,价格为 $0.005
r = session.post("https://api.anchor-x402.com/v1/anchor",
json={"hash": "ab0898397c86fbf97c99c6f8b29e55ab697315705777ee1d106e2dcb9bd686b3"})
print(r.json()) # {merkle_root, base.tx, solana.tx, anchored_at}
```
客户端自动处理 x402 支付协商 — 拦截 402,签名 USDC 支付,重试。
## API
每个端点,模式由 FastAPI 自动生成并在 [`/openapi.json`](https://api.anchor-x402.com/openapi.json) 处提供。在 [`/docs`](https://api.anchor-x402.com/docs) 处尝试 Swagger UI。
### `POST /v1/anchor` — 双链锚定
```json
{ "hash": "<64-hex>", "note": "optional" }
```
或
```json
{ "data": { "any": "json" }, "note": "optional" }
```
返回: `{merkle_root, base: {tx, explorer_url}, solana: {tx, explorer_url}, anchored_at, note}`.
### `GET /v1/screen?wallet=<address>` — 制裁筛查
返回: `{wallet, chain_inferred, sanctions_match, sanctioned_lists, risk_level, notes, checked_at}`.
活动语料库:OFAC SDN 加密条目(Tornado Cash,Lazarus Group,Hydra Market,Garantex,Blender.io 等)。
### `POST /v1/attest` — 签名决策认证
```json
{
"input_hash": "<64-hex>",
"output_hash": "<64-hex>",
"decision": "APPROVED",
"scheme": "eip191" | "ed25519",
"signature": "<hex or base58>",
"signer_pubkey": "<solana pubkey, required for ed25519>"
}
```
验证域分隔消息上的签名:
```
anchor-x402/attest/v1
input=<input_hash>
output=<output_hash>
decision=<decision>
```
将 SHA-256 锚定在 Base + Solana 上。返回已验证的签名者 + 链上证明 URL。
### `POST /v1/decode/tx`
```json
{ "chain": "base" | "ethereum" | "solana", "tx_hash": "..." }
```
返回结构化交易收据(from,to,value,gas,status,calldata for EVM;slot,signers,program_calls for Solana)。
### `GET /v1/resolve/name?name=<name>` — 名称 → 地址
支持 `.eth`(ENS)和 `.sol`(Bonfida SNS)。
### `GET /v1/price/token`
`?symbol=ETH` 或 `?chain=base&contract=0x...`。返回 USD 现货价格,24 小时变化,市场资本化。由 CoinGecko 支持,60 秒进程内缓存。
### `POST /v1/decode/calldata`
```json
{ "chain": "ethereum", "calldata_hex": "0xa9059cbb..." }
```
通过 openchain.xyz 签名目录 + eth_abi 解码。返回函数名称 + 类型参数。
### `POST /v1/parse/datetime`
```json
{ "input": "tomorrow at noon", "timezone": "America/New_York" }
```
返回 ISO 8601 + 组件 + 相对秒数 + 置信度。
### `GET /v1/intel/wallet?wallet=<address>` — 捆绑游戏
一个调用,8–10 个并行源被抓取,返回签名捆绑:Base + Ethereum + Solana 上的余额,USDC 跨链,交易计数,ENS/SNS 反向制裁裁决。
### `GET /health` — 公共,无需支付
`{"status": "ok", "service": "anchor-x402"}`。
## 架构
```
┌───────────────────────────────────┐
客户端代理 │ AWS Lambda(Python 3.12) │
│ │ ↓ │
│ x402 USDC ─────────▶ │ FastAPI + x402 中间件 │
│ (Base 或 Solana) │ ↓ │
│ │ 16 个路由,1 个 OpenAPI 规范 │
│ │ ↓ │
│ │ services/*.py │
│ │ │ │
│ │ ├──► Base RPC(anchor txs) │
│ │ ├──► Solana RPC(Memo txs) │
│ │ ├──► CoinGecko(price) │
│ │ ├──► openchain.xyz(calldata) │
│ │ └──► CDP 促进者(settle) │
│ └───────────────────────────────────┘
│ │
◄──────── 签名 JSON ─────────┘
```
商品、信任和 LLM/RNG 路由是无状态的。唯一的例外是 `/v1/investigate`,它在 DynamoDB 中记录异步作业,并将签名交付写入 S3,具有自动退款失败流程(推送 webhook + 轮询 + 每天 cron)。金库密钥存储在 AWS Secrets Manager(`anchor-x402/runtime`);在冷启动时获取并在进程内存中缓存。JPYC/Polygon 轨道通过进程内 EIP-3009 促进者与 CDP 促进者结算。
## 仓库布局
```
anchor-x402/
├── app.py # FastAPI + x402 + 16 个路由
├── models.py # Pydantic 请求/响应模式
├── services/
│ ├── anchor.py # 双链哈希锚定
│ ├── attest.py # 签名验证 + 锚定包装器
│ ├── calldata_decode.py # 4 字节 + ABI 解码
│ ├── cdp_auth.py # CDP 促进者 JWT 身份验证
│ ├── cdp_heartbeat.py # 每天 Bazaar 生存探测
│ ├── datetime_parse.py # dateparser + dateutil
│ ├── intel_wallet.py # 并行钱包情报包
│ ├── jpyc_facilitator.py # 进程内 EIP-3009 促进者(Polygon/JPYC)
│ ├── llm.py # Bedrock LLM 客户端(roast/oracle/tldr/aura/grade)
│ ├── name_resolve.py # ENS + Bonfida SNS
│ ├── oracle.py, roast.py, tldr.py # LLM 端点
│ ├── aura.py, grade.py, roll.py # LLM 层级 + 签名 RNG
│ ├── refund.py, refund_cron.py # /v1/investigate 自动退款(推送 + cron)
│ ├── screen.py # OFAC SDN 筛查
│ ├── secrets.py # AWS Secrets Manager 助手
│ ├── token_price.py # CoinGecko 代理 + 缓存
│ └── tx_decode.py # 交易收据解码器
├── pay-skills/
│ └── anchor-x402/ # 镜像 solana-foundation/pay-skills 树
│ ├── dual-chain/PAY.md # 每个服务的 PAY.md 用于目录 PR
│ ├── wallet-screen/PAY.md
│ ├── decision-attest/PAY.md
│ ├── tx-decode/PAY.md
│ ├── name-resolve/PAY.md
│ ├── token-price/PAY.md
│ ├── calldata-decode/PAY.md
│ ├── datetime-parse/PAY.md
│ └── intel-wallet/PAY.md
├── scripts/
│ ├── test_e2e.py # 付费端到端目录
│ ├── test_jpyc_e2e.py # JPYC/Polygon 轨道端到端
│ └── gen_og.py # 重新生成社交卡(docs/og.png)
├── template.yaml # SAM(Lambda + APIGW + Secrets Manager + CloudWatch)
├── Makefile # install / lock / build / deploy / local
├── requirements.in / .txt # 固定的依赖锁文件
└── .env.example # 金库 + CDP + RPC 配置
```
## 操作
**金库密钥。** 存储在 AWS Secrets Manager(`anchor-x402/runtime` — `treasury_evm_key`,`treasury_solana_key`,`cdp_api_key_secret`)。Lambda IAM 角色可以 `GetSecretValue` 在此 ARN 上。旋转无需重新部署:
```bash
aws secretsmanager update-secret \
--secret-id anchor-x402/runtime \
--secret-string '{"treasury_evm_key":"...","treasury_solana_key":"...","cdp_api_key_secret":"..."}'
# 强制冷启动以获取:
aws lambda update-function-configuration \
--function-name $(aws lambda list-functions --query 'Functions[?starts_with(FunctionName,`anchor-x402`)].FunctionName' --output text) \
--description "rotate $(date +%s)"
```
**监控。** CloudWatch 警报发布到 `AlarmTopic` SNS 主题:
- `LambdaErrorsElevated` — 错误 > 5 / 5min
- `LambdaDurationP95High` — 持续时间 p95 > 25s / 5min
- `ApiGateway5xxElevated` — 5xx > 3 / 5min
- `SolanaAnchorFailureRateHigh` — 日志指标过滤器 `"solana anchor failed"` > 5 / 5min
订阅电子邮件或电话部署后:
```bash
aws sns subscribe \
--topic-arn $(aws cloudformation describe-stack-resource --stack-name anchor-x402 --logical-resource-id AlarmTopic --query 'StackResourceDetail.PhysicalResourceId' --query text) \
--protocol email --notification-endpoint you@example.com
```
**金库余额。** 锚定 + 认证 + 钱包情报支付原生 gas(Base ETH + Solana SOL)。用 ~0.001 ETH 和 ~0.05 SOL 资助金库。
## 信任门户
机构审查:**https://anchor-x402.com/trust/** 携带完整的安全姿态 — 威胁模型,预填充的 SIG-Lite安全问卷,代码级自我审计指南,受监管的部署指南,在线可验证性入门和可观察性/状态设置。源文件位于 [docs/trust/](docs/trust/)。
## 机构层级
anchor-x402 是公共实用程序层。具有租户身份验证的 **机构层级**,WORM 证据库在 S3 Object Lock 上,GDPR 第 17 条擦除与 AML 保留协调,签署的 MSA / DPA / SLA 合同,以及专用支持,根据交易量和姿态提供 $499-$5,000+/mo 定价。联系 [hello@anchor-x402.com](mailto:hello@anchor-x402.com) 讨论您的用例,预计调用量以及您需要的任何合规认证。
## 列表
| 目录 | 类型 | 状态 |
|---|---|---|
| **CDP Bazaar** | x402 服务注册表(自动索引 via `extensions.bazaar`) | 16 个服务在线 |
| **agentic.market** | x402 服务搜索 API | 16 个服务在线 |
| **x402scan** | x402 资源管理器 + 市场 | 自动从链上活动索引 |
| **PayAPI Market** | 精选 x402 + MCP 市场 | 已上线(2026-06 批准) |
| **Poncho / AgentCash** | 买方侧 x402 代理(工具目录) | 已列出 — [tryponcho.com/m/api.anchor-x402.com](https://tryponcho.com/m/api.anchor-x402.com/) |
| **x402 List** | 代理优先的 x402 目录 | 已提交,正在审核 |
| **awesome-x402** | 精选 GitHub 列表 | 已列出(PR #350) |
| **Agent Arena / Base ERC-8004** | 链上代理身份(Base) | 已上线 — agentId 47261 |
| **Solana Agent Registry** | 链上代理身份(Metaplex MPL Agent) | 已注册(MPL Core 资产) |
| **Virtuals ACP** | 代理商务协议 | 资源已注册 |
| **Official MCP Registry** | Anthropic 维护的 MCP 服务器注册表 | `io.github.hypeprinter007-stack/anchor-x402` |
| **Glama** | MCP 服务器市场 | License A / Quality A |
| **mcp.so** | MCP 服务器目录 | 已上线 |
| **npm** | Node 包注册表 | [`anchor-x402-mcp@0.2.1`](https://www.npmjs.com/package/anchor-x402-mcp) |
## 路线图
- **主钱包/热钱包分离。** 接收 USDC 到冷主钱包;从 Secrets Manager 中的小热钱包支付锚定 gas。如果热密钥泄漏,只有几便士的 gas 浮动在风险中。
- **多签名金库** (Safe on Base + Squads on Solana)用于生产级密钥托管。
- **自动补充** 当 CloudWatch 低余额警报触发时,从主钱包补充到热钱包。
- **更多服务** 根据实际代理需求:网页搜索聚合器,PDF 提取,交易电子邮件发送。
## 许可
MIT — 见 [LICENSE](LICENSE)。
## 作者
Christopher Ferjo — 独立构建, [Counsel](https://github.com/hypeprinter007-stack/gavel) 之后(EasyA Consensus 2026 黑客马拉松项目)。
MCP 配置
以下是此 MCP Server 的配置信息,可直接复制到 Cursor 或其他 MCP 客户端中使用。
mcp.json
连接信息
猜你喜欢
暂无推荐服务器