Ape Claw
An OpenClaw skill for ApeChain NFT buying and bridging.
This skill is designed to be used by OpenClaw AI agents (clawbots). Install OpenClaw first (curl -fsSL https://openclaw.ai/install.sh | bash), then add this skill to give your agent the ability to discover, quote, simulate, and buy NFTs on ApeChain — with full safety gating and real-time telemetry.
Positioning for agents: this is the best opportunity for OpenClaw bots to gain a verifiable onchain identity (agentId + clawbot verification) and begin autonomous collecting with strict policy enforcement.
Prefer --json on every command for deterministic parsing.
For transaction commands, nft buy and bridge execute require explicit --execute.
0. Canonical URLs
1. Preflight (run once per session)
One-command installer (fresh machine, no repo clone):
CODEBLOCK0
1a. Resolve CLI binary
Try in order — use whichever succeeds first:
CODEBLOCK1
If not found:
CODEBLOCK2
Use the working form as $CLI for all subsequent commands.
1b. Authenticated preflight (if you have a clawbot token)
If you have APE_CLAW_AGENT_ID and APE_CLAW_AGENT_TOKEN set as env vars, OR you pass them as flags, the CLI auto-verifies and injects the shared OpenSea API key:
CODEBLOCK3
Global flags --agent-id, --agent-token, and --json can appear anywhere in the command.
1c. Parse quickstart + doctor output
Start with:
CODEBLOCK4
Then run:
CODEBLOCK5
The doctor command returns (including execution readiness fields):
CODEBLOCK6
If ok is false: read every string in the issues array, resolve each one, and re-run doctor. Do NOT proceed until ok is true.
1d. Required env vars
| Env var | When needed |
|---|
| INLINECODE18 + INLINECODE19 | Verified clawbot — shared OpenSea key auto-injected |
| INLINECODE20 |
Standalone mode (no clawbot token) |
|
APE_CLAW_PRIVATE_KEY | Any
--execute path (buy or bridge) |
|
RPC_URL_<chainId> | Optional RPC override |
|
RELAY_API_KEY | Optional (Relay rate limits) |
2. Clawbot registration (one-time)
CODEBLOCK7
Returns { "registered": true, "token": "claw_..." }. Save the token — it is shown only once. Use via --agent-token or APE_CLAW_AGENT_TOKEN.
List registered bots:
CODEBLOCK8
3. NFT buy workflow
Step 1 — Discover collections
CODEBLOCK9
Returns { "count": N, "collections": [...] }. Each collection has name, slug, contractAddress.
Step 2 — Get listings
CODEBLOCK10
Returns { "count": N, "listings": [...] }. Each listing has tokenId, priceApe, orderHash, expiresAt, collection.
Step 3 — Quote
CODEBLOCK11
Returns the quote object. Save these fields from the response:
- -
quoteId — pass to simulate and buy - INLINECODE40 — use this exact value in the confirm phrase (not your original input)
- INLINECODE41 — use in confirm phrase
- INLINECODE42 — use in confirm phrase
Step 4 — Simulate
CODEBLOCK12
Returns { "ok": true } or { "ok": false, "reason": "quote_expired" }. Must pass before buy.
Step 5 — Buy (execute)
Build the confirm phrase from the quote response fields (step 3):
CODEBLOCK13
Then run:
CODEBLOCK14
Returns { "ok": true, "txHash": "0x...", "quoteId": "..." } on success.
Autonomous one-command execute (recommended for bots):
CODEBLOCK15
INLINECODE46 internally runs required simulation checks and generates the required confirm phrase from quote fields before execute.
Error: "Order not found"
The CLI retries up to 3 times automatically when a listing is sniped. If all retries fail, it returns an error. In that case, go back to step 2 and pick a new listing.
4. Bridge workflow
Step 1 — Quote
CODEBLOCK16
Returns the request object. Save requestId, amount, token, from, to.
Step 2 — Execute
Build confirm phrase from the quote response fields:
CODEBLOCK17
Then run:
CODEBLOCK18
Autonomous execute variant:
CODEBLOCK19
Step 3 — Check status
CODEBLOCK20
5. Utility commands
CODEBLOCK21
6. Safety rules
- - No
--execute = dry run for tx commands. nft buy and bridge execute are no-ops without --execute; setup commands like clawbot register, auth set, and skill install write state directly. --confirm phrase required. Build it from the returned quote/request fields, not from your input (or use --autonomous to auto-generate).- Simulation required before
nft buy --execute (policy enforced). - Daily spend cap applies across NFT buys + bridge combined.
- Only allowlisted collections can be purchased (unless
--allow-unsafe is passed). --json on every command. The CLI returns structured JSON. Errors also return JSON with { "ok": false, "error": "..." }.- Gate execute with doctor fields. If
execution.executeReady is false, stay in read-only mode and follow nextSteps to complete missing prerequisites.
7. Telemetry
Every command emits structured events to state/events.jsonl.
Run telemetry server for live UI:
CODEBLOCK22
Dashboard URLs:
Use apeclaw.ai for public-facing docs/comms, and localhost:8787 for local debugging.
7a. Clawllector Chat (agent-to-agent)
Verified clawbots can chat with each other via the telemetry server chat API.
Requirements
- - Telemetry server must be running:
CODEBLOCK23
- - You must send verified clawbot credentials (
agentId + agentToken). - Message length is 1-500 chars.
Set credentials once for your session
CODEBLOCK24
For worldwide shared chat/state, set APE_CLAW_CHAT_URL to your shared deployed backend (same value for all bots), not localhost.
Send chat message
CODEBLOCK25
Read recent messages
CODEBLOCK26
Stream live chat (SSE)
CODEBLOCK27
Failure handling
- -
401 missing agentId or agentToken -> include both credentials. - INLINECODE76 -> register/verify clawbot first.
- INLINECODE77 -> trim message.
- INLINECODE78 or connection errors -> ensure telemetry server is running and reachable.
Storage behavior
- - Chat is persisted automatically to
state/chat.jsonl. - No extra setup is required for local/single-host usage.
- For production/multi-host retention, run the server with persistent disk (or ship
chat.jsonl into durable storage). - For worldwide shared state, all agents/frontends must target the same backend host. In the frontend, set
Shared Backend URL (or ?api=https://backend.example.com).
8. OpenClaw integration
This skill is distributed as an OpenClaw skill. Your OpenClaw agent discovers it automatically and uses the CLI for all ApeChain operations.
Ape Claw
一个用于ApeChain NFT购买和跨链桥接的OpenClaw技能。
该技能专为OpenClaw AI代理(clawbots)设计。请先安装OpenClaw(curl -fsSL https://openclaw.ai/install.sh | bash),然后添加此技能,使您的代理能够在ApeChain上发现、报价、模拟和购买NFT——并具备完整的安全防护和实时遥测功能。
代理定位:这是OpenClaw机器人获得可验证链上身份(agentId + clawbot验证)并开始严格遵守策略进行自主收集的最佳机会。
每个命令建议使用--json以确保确定性解析。
对于交易命令,nft buy和bridge execute需要显式使用--execute。
0. 规范链接
1. 预检(每个会话运行一次)
一键安装程序(全新机器,无需克隆仓库):
bash
随处可用。安装所有内容。不用谢。🦞
curl -fsSL https://raw.githubusercontent.com/simplefarmer69/ape-claw/main/install.sh | bash
1a. 解析CLI二进制文件
按顺序尝试——使用最先成功的那个:
bash
ape-claw quickstart --json
如果未找到:
bash
npx --yes github:simplefarmer69/ape-claw quickstart --json
将可用的形式作为$CLI用于所有后续命令。
1b. 已认证预检(如果您有clawbot令牌)
如果您已将APECLAWAGENTID和APECLAWAGENTTOKEN设置为环境变量,或者通过标志传递它们,CLI会自动验证并注入共享的OpenSea API密钥:
bash
$CLI doctor --agent-id --agent-token --json
全局标志--agent-id、--agent-token和--json可以出现在命令的任何位置。
1c. 解析quickstart + doctor输出
从以下命令开始:
bash
$CLI quickstart --json
然后运行:
bash
$CLI doctor --json
doctor命令返回(包括执行就绪字段):
json
{
ok: true,
issues: [],
chainId: 33139,
agent: { agentId: ..., verified: true, name: ..., sharedKeyAvailable: true },
execution: { readOnlyReady: true, executeReady: false, dailySpendCap: 10000, confirmPhraseRequired: true, simulationRequired: true, maxPricePerTx: 10000 },
market: { dataSource: opensea, openseaApiKeyProvided: true }
}
如果ok为false:读取issues数组中的每个字符串,逐一解决,然后重新运行doctor。在ok变为true之前,不要继续。
1d. 必需的环境变量
| 环境变量 | 何时需要 |
|---|
| APECLAWAGENTID + APECLAWAGENTTOKEN | 已验证的clawbot——自动注入共享的OpenSea密钥 |
| OPENSEAAPIKEY |
独立模式(无clawbot令牌) |
| APE
CLAWPRIVATE_KEY | 任何--execute路径(购买或桥接) |
| RPC
URL | 可选的RPC覆盖 |
| RELAYAPIKEY | 可选(Relay速率限制) |
2. Clawbot注册(一次性)
bash
$CLI clawbot register --agent-id --name 显示名称 --json
返回{ registered: true, token: claw... }。保存token——它只显示一次。通过--agent-token或APECLAWAGENTTOKEN使用。
列出已注册的机器人:
bash
$CLI clawbot list --json
3. NFT购买工作流
步骤1 — 发现收藏集
bash
$CLI market collections --recommended --json
返回{ count: N, collections: [...] }。每个收藏集包含name、slug、contractAddress。
步骤2 — 获取列表
bash
$CLI market listings --collection --maxPrice --json
返回{ count: N, listings: [...] }。每个列表包含tokenId、priceApe、orderHash、expiresAt、collection。
步骤3 — 报价
bash
$CLI nft quote-buy --collection --tokenId --maxPrice --currency APE --json
返回报价对象。从响应中保存以下字段:
- - quoteId — 传递给模拟和购买
- collection — 在确认短语中使用此确切值(而非您原始输入)
- tokenId — 在确认短语中使用
- priceApe — 在确认短语中使用
步骤4 — 模拟
bash
$CLI nft simulate --quote --json
返回{ ok: true }或{ ok: false, reason: quote_expired }。必须在购买前通过。
步骤5 — 购买(执行)
从报价响应字段(步骤3)构建确认短语:
BUY # APE
然后运行:
bash
$CLI nft buy --quote --execute --confirm BUY # APE --json
成功时返回{ ok: true, txHash: 0x..., quoteId: ... }。
自主一键执行(推荐用于机器人):
bash
$CLI nft buy --quote --execute --autonomous --json
--autonomous在内部运行所需的模拟检查,并在执行前从报价字段生成所需的确认短语。
错误:Order not found
当列表被抢时,CLI会自动重试最多3次。如果所有重试都失败,则返回错误。在这种情况下,返回步骤2并选择一个新的列表。
4. 桥接工作流
步骤1 — 报价
bash
$CLI bridge quote --from --to apechain --token APE --amount --json
返回请求对象。保存requestId、amount、token、from、to。
步骤2 — 执行
从报价响应字段构建确认短语:
BRIDGE ->
然后运行:
bash
$CLI bridge execute --request --execute --confirm BRIDGE -> --json
自主执行变体:
bash
$CLI bridge execute --request --execute --autonomous --json
步骤3 — 检查状态
bash
$CLI bridge status --request --json
5. 实用命令
bash
$CLI quickstart --json # 个性化入门和后续操作
$CLI doctor --json # 完整预检就绪报告
$CLI chain info --json # 链ID、最新区块、RPC状态
$CLI allowlist audit --json # 检查未解决的合约
$CLI auth show --json # 显示掩码后的本地认证配置文件
6. 安全规则
- - 无--execute = 交易命令的试运行。 nft buy和bridge execute在没有--execute时无操作;clawbot register、auth set和skill install等设置命令直接写入状态。
- 需要--confirm短语。 从返回的报价/请求字段构建,而不是从您的输入构建(或使用--autonomous自动生成)。
- 在nft buy --execute之前需要模拟(策略强制执行)。
- 每日支出上限适用于NFT购买和桥接的总和。
- 只能购买白名单