transaction-receipt (On-chain receipt translator)
Environment and configuration
| Variable | Required | Secret | If missing |
|---|
| INLINECODE0 | No | Yes | Do not call Tokenview; use public Fallback (below). Recommend users obtain a key at tokenview.io for richer, more uniform payloads. |
| INLINECODE1 |
No | No | Default
30: cap all on-chain lookups (Tokenview or Fallback) at
30 per hour per machine user. |
|
TRANSACTION_RECEIPT_RATE_FILE | No | No | Default to
~/.openclaw/state/transaction-receipt/rate-limit.log. Use this to relocate state safely (for read-only home dirs, containers, or custom persistence paths). |
Dependency: curl must be available. If not, explain that this skill cannot run and suggest installing curl. Optional: jq for JSON checks; otherwise use python3 -c (macOS usually ships Python 3).
API key flow (user-first, then public, then friendly failure)
- 1. Prefer the user’s key: At onboarding or before the first lookup of a session, gently ask whether they have configured
TOKENVIEW_API_KEY in their environment or OpenClaw settings (do not ask them to paste the full key in chat). - If a key is configured (non-empty): Use Tokenview as the primary path.
- If no key is configured: Use only the public Fallback path—this is normal, not an error.
- If a key is configured but invalid / expired: After detecting auth failure, automatically switch to Fallback and briefly tell the user: e.g. “Your Tokenview key could not be used; results are from a public data source instead.”
- If both paths fail or the tx cannot be found: Give a short, friendly message (network issue, wrong chain, not yet broadcast, hash typo, or rate limit). Do not dump raw responses.
Never echo, display, or ask the user to paste a complete API key.
Onboarding (first-time users)
If the user seems new, say something like:
Welcome! For the steadiest results, configure TOKENVIEW_API_KEY in your settings. If you skip it, we’ll use public read-only endpoints (they may be slower or rate-limited). You can get a key at tokenview.io.
When to activate
Enable when the user uses this skill or when a message contains an extractable on-chain hash:
- 1. BTC txid: exactly 64 hex chars (
0-9, a-f, A-F), no 0x prefix. - EVM tx hash: starts with
0x, total length 66, next 64 chars are hex.
Bounded input: After trim, take the first token that passes validation. Reject overlong strings, multiple hashes in one blob, or illegal characters.
Rate limiting (P0 — before any on-chain request)
Goal: Avoid burning Tokenview quota or getting public nodes blocked.
- 1. Resolve hourly cap:
MAX="${TRANSACTION_RECEIPT_MAX_PER_HOUR:-30}". - Resolve state path in this order:
- If
TRANSACTION_RECEIPT_RATE_FILE is set, use it directly.
- Else use
~/.openclaw/state/transaction-receipt/rate-limit.log.
- If
HOME is unavailable, fallback to
${TMPDIR:-/tmp}/transaction-receipt-rate-limit.log.
- 3. Ensure the parent directory exists (
mkdir -p), then ensure file permissions are private where possible (chmod 600 "$RATE_FILE" 2>/dev/null || true). - Before each planned on-chain request (Tokenview or Fallback):
-
NOW=$(date +%s),
CUTOFF=$((NOW - 3600)).
- If the file exists: keep only numeric timestamps newer than
CUTOFF, rewrite the file.
- Enforce a hard cap on retained rows (e.g. keep the most recent 10,000 lines) to prevent unbounded growth.
-
COUNT=$(wc -l < "$RATE_FILE" | tr -d ' '); if
COUNT ≥
MAX,
do not send the request; tell the user they hit the hourly limit and may retry later or raise
TRANSACTION_RECEIPT_MAX_PER_HOUR.
- If under cap:
echo "$NOW" >> "$RATE_FILE", then proceed.
- 5. If the state file cannot be written (permission or filesystem issue), continue with an in-memory/session-only counter and clearly note that rate limiting persistence is degraded.
Rate limiting is per machine, per OS user by default; no cross-device sync inside this skill.
Actions (data routing)
Shared: curl timeouts (P0)
Every curl call must include:
INLINECODE32
1. Extract hash and environment
Extract HASH from user input. Treat non-empty TOKENVIEW_API_KEY as “key configured.”
2. Source selection
- - Key configured: Tokenview first.
- Key not configured: Fallback only.
- Key configured but invalid: after auth failure, Fallback (do not stop the flow).
3-A. Primary: Tokenview (GET)
After rate limit, run (expand HASH / key in the shell; never print full URL or key to the user):
EVM (HASH starts with 0x):
CODEBLOCK0
BTC (64 hex, no 0x):
CODEBLOCK1
Doc shorthand: https://services.tokenview.io/vipapi/tx/eth|btc/{{hash}}?apikey={{TOKENVIEW_API_KEY}} (still use curl timeouts).
3-B. Fallback: public read-only (no key or bad key)
Use when no key or Tokenview auth failure. Same rate limit and curl timeouts.
EVM: JSON-RPC POST (example mainnet: https://ethereum.publicnode.com; one silent retry on another public endpoint such as https://1rpc.io/eth is allowed—do not paste verbose retry logs to the user).
- 1.
eth_getTransactionByHash:
CODEBLOCK2
- 2. If
result is not null, call eth_getTransactionReceipt with the same URL and params: ["${HASH}"] for success/failure (status) and logs (needed to classify Swap / Approve / NFT / staking).
Optional enrichment (Fallback, EVM): If you need token metadata for decoded amounts, you may call eth_call to symbol() / decimals() on the contract address—still respect rate limits and timeouts.
BTC: GET Blockstream:
CODEBLOCK3
404 / 429: map to friendly errors; never paste huge raw JSON.
3-C. Tokenview key validity
If TOKENVIEW_API_KEY is set:
- 1. HTTP 401/403 → switch to Fallback.
- Body indicates invalid key / forbidden / unauthorized (case-insensitive) → Fallback.
- If Fallback also fails, one short user-facing error—no dual full payloads.
Scope of txid interpretation (beyond “plain transfer”)
The skill applies to any valid BTC or EVM tx hash. After you have validated JSON (Tokenview or RPC), classify the interaction and tailor the narrative:
A. Simple transfer (native or ERC-20)
- - Goal: State clearly who sent what to whom (from → to, asset, human-readable amount).
- Use
from / to / value for native transfers; for ERC-20, infer from Transfer logs (topics[0] typically 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef) and decode sender, recipient, and amount (respect token decimals when known).
B. Swap / trade (DEX aggregation, router calls, etc.)
- - Goal: Summarize what the user paid and what they received (assets + approximate amounts).
- Use decoded logs (e.g. Swap/Sync/Mint/Burn style events), Tokenview’s decoded fields if present, or internal transfers—best effort. If legs are ambiguous, say what is certain and mark the rest as “not fully decoded.”
C. Approve (ERC-20 allowance)
- - Goal: Use a warning tone.
- Clearly state: the user authorized a spender (typically
spender in the Approval log) to move up to X of token Y on their behalf. Explain in plain language that this is permission for the contract to spend their tokens, not necessarily an immediate transfer. - Do not panic-monger; be factual and prominent (e.g. “⚠️ Approval: you granted spending rights…”).
D. DeFi: stake / unstake / deposit / withdraw / claim (and similar)
- - Describe the observable asset movements and the contract the user called.
- If decoding is incomplete: fallback to: “You interacted with a smart contract at
0x… (short + full address). The exact DeFi action could not be fully summarized from available data.”
E. NFT: mint / transfer (ERC-721 / ERC-1155)
- - Mint: e.g. “You minted” or “NFT(s) were minted to your address,” with collection/name if available from logs or metadata hints.
- Transfer: who sent which NFT id (and quantity for 1155) to whom.
- If only
Transfer with unknown collection, still report addresses and token id.
F. Other complex contract calls
- - If the tx is not clearly A–E above: use the plain-language fallback: “You performed an on-chain interaction with smart contract
0x….” Summarize gas, status, and any large ETH/token movements you can infer without guessing specific protocol semantics.
Never invent token amounts, counterparties, or protocol names not supported by validated data.
Response validation (P1)
Before writing the receipt, validate structure. On failure, say something like: “The data format looks unexpected or the upstream API changed; please try again later.” Do not fabricate balances or status.
General: Body must be valid JSON (python3 -c 'import json,sys; json.load(sys.stdin)' or jq).
Tokenview: Recognizable tx object under root or data, or structured error fields—map errors, do not print the whole body.
EVM JSON-RPC: jsonrpc is "2.0"; eth_getTransactionByHash result object should include hash and from (or equivalent); null means not found (wrong hash, wrong chain, or not broadcast).
BTC Blockstream: top-level must include txid.
Validation is internal; do not print schemas or raw bodies to the user.
Errors and degradation
- - Non-2xx HTTP, timeouts, curl errors: short human explanation; no full upstream body.
- No key: Fallback only—normal path.
- Bad key: Fallback after detection; brief notice.
- Nothing found after both paths: friendly message (check network, chain, spelling, pending tx).
Voice and output shape
Voice: Calm, patient Web3 concierge.
Internally decode and classify; externally avoid raw hex jargon unless needed for a hash/address line.
Receipt must include:
- 1. Status: success / failed / pending (with plain wording).
- Overview: chain (BTC / EVM), full tx hash, time if known, block / height if known, confirmations if known.
- Interaction summary: per classification above (transfer / swap paid↔received / ⚠️ approve / NFT / DeFi / generic contract).
- Fees: clear units; EVM include
gasUsed and effective gas price when available; BTC include fee rate if available. - One-line takeaway: plain-language wrap-up.
- Footer (required, last line only): INLINECODE72
Final checks before send (mandatory)
- 1. If the body lacks the footer, append one line: INLINECODE73
- Remove any of these if they appear in the body:
-
Sourced from public Ethereum RPC
-
transaction-receipt v1.1.1
- 3. Do not print version banners (e.g.
transaction-receipt v*, bare v1.x.x). - The last line of the message must be exactly
Data aggregated by Antalpha AI (no trailing text, blank lines, or ellipsis after it).
Presentation:
- - Addresses: short form + full when space allows (e.g.
0x12ab…89ef (0x12ab…full…)). - Numbers: human-readable with sane precision; note unit conversions when helpful (e.g. wei → ETH).
- Missing fields: say “not returned” / “unavailable,” never leave silent gaps.
- Never paste raw JSON blobs, long hex dumps, or full RPC payloads.
Security (production)
- - Never print full raw JSON responses or full API bodies.
- Never print
TOKENVIEW_API_KEY. - User-facing content = receipt summary + short errors only.
Versioning
- - Skill id:
transaction-receipt; this document version: 1.1.1. Bump version and distribution together when you change behavior.
transaction-receipt(链上收据翻译器)
环境与配置
| 变量 | 是否必需 | 是否机密 | 缺失时的处理 |
|---|
| TOKENVIEWAPIKEY | 否 | 是 | 不调用Tokenview;使用公共备用方案(见下文)。建议用户在 tokenview.io 获取密钥以获得更丰富、更统一的数据。 |
| TRANSACTIONRECEIPTMAXPER_HOUR |
否 | 否 | 默认值
30:每台机器用户每小时所有链上查询(Tokenview或备用方案)上限为
30次。 |
| TRANSACTION
RECEIPTRATE_FILE | 否 | 否 | 默认为 ~/.openclaw/state/transaction-receipt/rate-limit.log。用于安全地重新定位状态文件(适用于只读主目录、容器或自定义持久化路径)。 |
依赖项: 必须安装 curl。如果未安装,说明此技能无法运行并建议安装 curl。可选:jq 用于JSON检查;否则使用 python3 -c(macOS通常自带Python 3)。
API密钥流程(用户优先,然后公共,最后友好提示失败)
- 1. 优先使用用户的密钥: 在引导阶段或会话首次查询前,温和地询问用户是否已在环境变量或OpenClaw设置中配置了 TOKENVIEWAPIKEY(不要要求用户在聊天中粘贴完整密钥)。
- 如果已配置密钥(非空): 使用Tokenview作为主要路径。
- 如果未配置密钥: 仅使用公共备用路径——这是正常情况,不是错误。
- 如果密钥已配置但无效/过期: 检测到认证失败后,自动切换到备用方案并简要告知用户:例如“您的Tokenview密钥无法使用;结果来自公共数据源。”
- 如果两个路径都失败或无法找到交易: 给出简短、友好的消息(网络问题、链错误、尚未广播、哈希拼写错误或速率限制)。不要输出原始响应。
切勿回显、显示或要求用户粘贴完整的API密钥。
引导(首次用户)
如果用户看起来是新手,请说类似以下内容:
欢迎!为了获得最稳定的结果,请在设置中配置 TOKENVIEWAPIKEY。如果跳过此步骤,我们将使用公共只读端点(可能较慢或受速率限制)。您可以在 tokenview.io 获取密钥。
何时激活
当用户使用此技能或消息中包含可提取的链上哈希时启用:
- 1. BTC交易ID: 恰好 64 个十六进制字符(0-9、a-f、A-F),无 0x 前缀。
- EVM交易哈希: 以 0x 开头,总长度 66,后续 64 个字符为十六进制。
输入限制: 在 trim 后,取第一个通过验证的令牌。拒绝过长的字符串、单个文本中的多个哈希或非法字符。
速率限制(P0 — 在任何链上请求之前)
目标: 避免消耗Tokenview配额或导致公共节点被屏蔽。
- 1. 解析每小时上限:MAX=${TRANSACTIONRECEIPTMAXPERHOUR:-30}。
- 按以下顺序解析状态路径:
- 如果设置了 TRANSACTION
RECEIPTRATE_FILE,直接使用。
- 否则使用 ~/.openclaw/state/transaction-receipt/rate-limit.log。
- 如果 HOME 不可用,回退到 ${TMPDIR:-/tmp}/transaction-receipt-rate-limit.log。
- 3. 确保父目录存在(mkdir -p),然后尽可能设置文件权限为私有(chmod 600 $RATE_FILE 2>/dev/null || true)。
- 每次计划发起链上请求(Tokenview或备用方案)之前:
- NOW=$(date +%s),CUTOFF=$((NOW - 3600))。
- 如果文件存在:仅保留时间戳大于 CUTOFF 的数字行,重写文件。
- 对保留的行数设置硬上限(例如保留最近10,000行),防止无限增长。
- COUNT=$(wc -l < $RATE
FILE | tr -d );如果 COUNT ≥ MAX,不发送请求;告知用户已达到每小时限制,可以稍后重试或提高 TRANSACTIONRECEIPT
MAXPER_HOUR。
- 如果未达到上限:echo $NOW >> $RATE_FILE,然后继续。
- 5. 如果无法写入状态文件(权限或文件系统问题),继续使用内存/会话计数器,并明确说明速率限制持久化功能已降级。
速率限制默认按机器、按操作系统用户执行;此技能内部不进行跨设备同步。
操作(数据路由)
共享:curl超时(P0)
每次 curl 调用必须包含:
--connect-timeout 5 --max-time 30
1. 提取哈希和环境
从用户输入中提取 HASH。将非空的 TOKENVIEWAPIKEY 视为“已配置密钥”。
2. 源选择
- - 已配置密钥: 优先使用Tokenview。
- 未配置密钥: 仅使用备用方案。
- 密钥已配置但无效: 认证失败后,使用备用方案(不停止流程)。
3-A. 主要路径:Tokenview(GET)
通过速率限制后,运行(在shell中展开 HASH/密钥;切勿向用户打印完整URL或密钥):
EVM(HASH 以 0x 开头):
bash
curl -sS --connect-timeout 5 --max-time 30 \
https://services.tokenview.io/vipapi/tx/eth/${HASH}?apikey=${TOKENVIEWAPIKEY}
BTC(64位十六进制,无 0x):
bash
curl -sS --connect-timeout 5 --max-time 30 \
https://services.tokenview.io/vipapi/tx/btc/${HASH}?apikey=${TOKENVIEWAPIKEY}
文档简写:https://services.tokenview.io/vipapi/tx/eth|btc/{{hash}}?apikey={{TOKENVIEWAPIKEY}}(仍需使用curl超时)。
3-B. 备用方案:公共只读(无密钥或密钥无效)
在无密钥或Tokenview认证失败时使用。相同的速率限制和curl超时。
EVM: JSON-RPC POST(示例主网:https://ethereum.publicnode.com;允许静默重试一次到另一个公共端点,如 https://1rpc.io/eth——不要向用户输出详细的重试日志)。
- 1. eth_getTransactionByHash:
bash
curl -sS --connect-timeout 5 --max-time 30 -X POST \
-H Content-Type: application/json \
-d {\jsonrpc\:\2.0\,\method\:\eth_getTransactionByHash\,\params\:[\${HASH}\],\id\:1} \
https://ethereum.publicnode.com
- 2. 如果 result 不为空,使用相同URL和 params: [${HASH}] 调用 eth_getTransactionReceipt 获取成功/失败(status)和日志(用于分类Swap/Approve/NFT/质押)。
可选增强(备用方案,EVM): 如果需要解码金额的代币元数据,可以调用 eth_call 获取合约地址的 symbol() / decimals()——仍需遵守速率限制和超时。
BTC: GET Blockstream:
bash
curl -sS --connect-timeout 5 --max-time 30 \
https://blockstream.info/api/tx/${HASH}
404 / 429:映射为友好错误;切勿粘贴大量原始JSON。
3-C. Tokenview密钥有效性
如果设置了 TOKENVIEWAPIKEY:
- 1. HTTP 401/403 → 切换到备用方案。
- 响应体指示密钥无效/禁止/未授权(不区分大小写)→ 使用备用方案。
- 如果备用方案也失败,给出一个简短的用户可见错误——不输出双重完整数据。
交易ID解释范围(超越“普通转账”)
此技能适用于任何有效的BTC或EVM交易哈希。验证JSON(Tokenview或RPC)后,分类交互并定制叙述:
A. 简单转账(原生或ERC-20)