当前位置: 首页 > Skill >

Transaction Receipt

Transaction Receipt

Transaction Receipt

链上交易可读收据,解析状态、费用和意图:简单转账、兑换/交易、代币授权、DeFi 质押类调用等。

1.1.2 2026.11.25 190
获取Skill文件查看使用说明
作 者:周言 许可证: 更新时间:2026.11.25
本文目录展开

transaction-receipt (On-chain receipt translator)

Environment and configuration

Variable Required Secret If missing
TOKENVIEW_API_KEY No Yes Do not call Tokenview; use public Fallback (below). Recommend users obtain a key at tokenview.io for richer, more uniform payloads.
TRANSACTION_RECEIPT_MAX_PER_HOUR 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).
  2. If a key is configured (non-empty): Use Tokenview as the primary path.
  3. If no key is configured: Use only the public Fallback path—this is normal, not an error.
  4. 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.”
  5. 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.
  2. 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}".
  2. 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).
  4. 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:

--connect-timeout 5 --max-time 30

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):

curl -sS --connect-timeout 5 --max-time 30 
  "https://services.tokenview.io/vipapi/tx/eth/${HASH}?apikey=${TOKENVIEW_API_KEY}"

BTC (64 hex, no 0x):

curl -sS --connect-timeout 5 --max-time 30 
  "https://services.tokenview.io/vipapi/tx/btc/${HASH}?apikey=${TOKENVIEW_API_KEY}"

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:
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"
  1. 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:

curl -sS --connect-timeout 5 --max-time 30 
  "https://blockstream.info/api/tx/${HASH}"

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.
  2. Body indicates invalid key / forbidden / unauthorized (case-insensitive) → Fallback.
  3. 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).
  2. Overview: chain (BTC / EVM), full tx hash, time if known, block / height if known, confirmations if known.
  3. Interaction summary: per classification above (transfer / swap paid↔received / ⚠️ approve / NFT / DeFi / generic contract).
  4. Fees: clear units; EVM include gasUsed and effective gas price when available; BTC include fee rate if available.
  5. One-line takeaway: plain-language wrap-up.
  6. Footer (required, last line only): Data aggregated by Antalpha AI

Final checks before send (mandatory)

  1. If the body lacks the footer, append one line: Data aggregated by Antalpha AI
  2. 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).
  4. 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.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
Skill 文件
  • SKILL.md
    • transaction-receipt (On-chain receipt translator)
    • Environment and configuration
    • API key flow (user-first, then public, then friendly failure)
    • Onboarding (first-time users)
    • When to activate
    • Rate limiting (P0 — before any on-chain request)
    • Actions (data routing)
      • Shared: curl timeouts (P0)
      • 1. Extract hash and environment
      • 2. Source selection
      • 3-A. Primary: Tokenview (GET)
      • 3-B. Fallback: public read-only (no key or bad key)
      • 3-C. Tokenview key validity
    • Scope of txid interpretation (beyond “plain transfer”)
      • A. Simple transfer (native or ERC-20)
      • B. Swap / trade (DEX aggregation, router calls, etc.)
      • C. Approve (ERC-20 allowance)
      • D. DeFi: stake / unstake / deposit / withdraw / claim (and similar)
      • E. NFT: mint / transfer (ERC-721 / ERC-1155)
      • F. Other complex contract calls
    • Response validation (P1)
    • Errors and degradation
    • Voice and output shape
      • Final checks before send (mandatory)
    • Security (production)
    • Versioning
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期