[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D6NTWZ6ZBFRF1NB2CPSQHY":3,"skill-same:01M7D6NTWZ6ZBFRF1NB2CPSQHY":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":13,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":40,"install":41,"resources":54},"01M7D6NTWZ6ZBFRF1NB2CPSQHY","onchain-monitor",null,"Monitor blockchain addresses and contracts for notable activity","LiamVisionary\u002Faeon-template","LiamVisionary","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F102138294?v=4","01M73379NZZ99TT4ZS17XR3Q9D","01M7D6D62V1SGGMKGT08Q1D2R8",0,"MIT","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fonchain-monitor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: onchain-monitor\ndescription: Monitor blockchain addresses and contracts for notable activity\nmetadata:\n  title: Onchain Monitor\n  category: crypto\n  var: \"\"\n  tags:\n    - crypto\n  requires:\n    - ALCHEMY_API_KEY?\n    - COINGECKO_API_KEY?\n    - ETHERSCAN_API_KEY?\n  capabilities:\n    - external_api\n    - sends_notifications\n---\n\u003C!-- autoresearch: variation B — sharper output (decoded transfers + counterparty labels + ranked USD-denominated one-liners + TL;DR lede); folds in A's Alchemy+Etherscan-v2 input path and C's persistent state + source-status footer + dedup. -->\n\n> **${var}** — Watch label or chain to check. Empty = all watches. `add-address:\u003C0x… [chain]>` is the shape the Telegram force-reply sends — it appends a new watch and exits (see step 0).\n\nIf `${var}` is set, only monitor the watch with that label or watches on that chain.\n\n## Config\n\nReads `memory\u002Fon-chain-watches.yml`. If the file is missing or `watches: []`, offer to add the first watch via a Telegram force-reply (only if no `add-address` prompt was offered in the last 2 days of `memory\u002Flogs\u002F` — dedup so an unconfigured fork isn't nagged every run), then log `ON_CHAIN_NO_CONFIG` and exit cleanly (do **not** send an alert — empty config is not an error):\n\n```bash\n.\u002Fnotify \"No addresses on watch yet. Paste one to monitor — a 0x… wallet, optionally its chain.\" \\\n  --force-reply --placeholder \"0x… base\" \\\n  --context \"onchain-monitor::add-address\"\n```\n\nThe reply routes back as `var=add-address:\u003C0x… [chain]>`, handled by the config-capture branch in step 0. Record `FORCE_REPLY_OFFERED: add-address` in the log when you send it.\n\n```yaml\n# memory\u002Fon-chain-watches.yml\nwatches:\n  - label: My Wallet\n    address: \"0x1234...abcd\"\n    chain: ethereum          # ethereum | base | arbitrum | optimism | polygon\n    type: wallet             # wallet | contract\n    threshold_usd: 1000      # alert on transfers ≥ this USD value (default 1000)\n  - label: Uniswap Pool\n    address: \"0xabcd...5678\"\n    chain: ethereum\n    type: contract\n    event_topics:            # optional — only alert on these topic0 hashes\n      - \"0xddf252ad...\"      # ERC20 Transfer\n```\n\nOptional `memory\u002Fknown-addresses.yml` — counterparty label dictionary used to humanize alerts. Lowercase keys, free-text values:\n```yaml\nlabels:\n  \"0x28c6c06298d514db089934071355e5743bf21d60\": \"Binance 14\"\n  \"0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43\": \"Coinbase 10\"\n  \"0xe592427a0aece92de3edee1f18e0157c05861564\": \"Uniswap V3 Router\"\n  \"0x0000000000000000000000000000000000000000\": \"Zero (mint\u002Fburn)\"\n```\n\n## State\n\n`memory\u002Fon-chain-state.json` — per-watch state, persisted atomically after each successful run:\n\n```json\n{\n  \"My Wallet\": {\n    \"last_block\": 19345678,\n    \"last_run\": \"2026-04-20T12:00:00Z\",\n    \"alerted_tx\": [\"0xabc...\", \"0xdef...\"],\n    \"median_usd_30d\": 8500\n  }\n}\n```\n\n- `last_block` — start block for the next run's fetch. Initialise to `current_block − 2400` (≈ 8h ETH) on first run.\n- `alerted_tx` — tx hashes alerted in last 7 days, capped at 200. Used for cross-run dedup.\n- `median_usd_30d` — rolling median USD size of transfers at this watch; powers the `WHALE-TRANSFER` tag.\n\nWrite the file via `mv` from a tempfile so a mid-run failure cannot corrupt state.\n\n## Steps\n\nRead `memory\u002FMEMORY.md`, `memory\u002Fon-chain-watches.yml`, `memory\u002Fon-chain-state.json`, and the last 2 days of `memory\u002Flogs\u002F` (for visibility only — state lives in the JSON file).\n\n### 0. Config capture (Telegram force-reply)\n\nBefore the per-watch loop, intercept the add-a-watch reply. When `${var}` starts with `add-address:`, the operator replied to the force-reply prompt (offered in the Config section on an empty config) — append a watch and **exit** (no monitoring this invocation). The remainder is `\u003Caddress> [chain]`:\n\n```bash\ncase \"${var}\" in\n  add-address:*)\n    REST=\"$(printf '%s' \"${var#add-address:}\" | sed 's\u002F^[[:space:]]*\u002F\u002F')\"\n    ADDR=\"$(printf '%s' \"$REST\" | awk '{print $1}')\"\n    CHAIN=\"$(printf '%s' \"$REST\" | awk '{print tolower($2)}')\"; CHAIN=\"${CHAIN:-ethereum}\"\n    case \"$CHAIN\" in ethereum|base|arbitrum|optimism|polygon) ;; *) CHAIN=ethereum ;; esac\n    if ! printf '%s' \"$ADDR\" | grep -qiE '^0x[0-9a-f]{40}$'; then\n      .\u002Fnotify \"Couldn't read \\\"$ADDR\\\" as an address. Reply with a 0x… wallet, optionally a chain.\"\n      exit 0\n    fi\n    mkdir -p memory; touch memory\u002Fon-chain-watches.yml\n    # Normalize an empty inline list so we can append block items, and ensure a watches: key exists.\n    sed -i.bak -E 's\u002F^watches:[[:space:]]*\\[\\][[:space:]]*$\u002Fwatches:\u002F' memory\u002Fon-chain-watches.yml && rm -f memory\u002Fon-chain-watches.yml.bak\n    grep -q '^watches:' memory\u002Fon-chain-watches.yml || printf 'watches:\\n' >> memory\u002Fon-chain-watches.yml\n    if grep -qi \"$ADDR\" memory\u002Fon-chain-watches.yml; then\n      .\u002Fnotify \"Already watching ${ADDR}.\"\n    else\n      SHORT=\"$(printf '%s' \"$ADDR\" | sed -E 's\u002F^(0x.{4}).*(.{4})$\u002F\\1…\\2\u002F')\"\n      cat >> memory\u002Fon-chain-watches.yml \u003C\u003CEOF\n  - label: \"$SHORT\"\n    address: \"$ADDR\"\n    chain: $CHAIN\n    type: wallet\n    threshold_usd: 1000\nEOF\n      .\u002Fnotify \"Now watching ${SHORT} on ${CHAIN} (wallet, moves ≥\\$1000). Edit memory\u002Fon-chain-watches.yml to tune.\"\n    fi\n    # log under ### onchain-monitor: - view: add-address (var=\"${var}\") → $ADDR on $CHAIN\n    exit 0 ;;\nesac\n```\n\nDefaults for a captured watch: `type: wallet`, `threshold_usd: 1000`, `label` = the shortened address. The operator refines chain\u002Ftype\u002Fthreshold by editing `memory\u002Fon-chain-watches.yml` directly. (This appends to the end of the file, which is correct because `watches:` is the only top-level key — if a future config grows more keys, insert under `watches:` instead of at EOF.)\n\nFor each watch (filtered by `${var}`):\n\n### 1. Fetch raw activity from `last_block` → latest\n\n**Path A — Alchemy** (preferred, if `ALCHEMY_API_KEY` set).\n\nWallets use `alchemy_getAssetTransfers` — one call returns categorized in\u002Fout history with `value`, `asset`, `category`, `hash`, `from`, `to`, `metadata.blockTimestamp`. Run it twice per watch (once with `toAddress`, once with `fromAddress`) and merge.\n\n```bash\n.\u002Fsecretcurl -m 10 -s -X POST \"https:\u002F\u002F${network}.g.alchemy.com\u002Fv2\u002F{ALCHEMY_API_KEY}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"alchemy_getAssetTransfers\",\"params\":[{\n    \"fromBlock\":\"0x'${from_block_hex}'\",\n    \"toAddress\":\"'${address}'\",\n    \"category\":[\"external\",\"internal\",\"erc20\",\"erc721\",\"erc1155\"],\n    \"withMetadata\":true,\"excludeZeroValue\":true,\"maxCount\":\"0x32\"\n  }]}'\n```\n\nContracts use `eth_getLogs` against the same Alchemy URL (Alchemy accepts up to ~10k block ranges).\n\nChain → network slug: `ethereum=eth-mainnet`, `base=base-mainnet`, `arbitrum=arb-mainnet`, `optimism=opt-mainnet`, `polygon=polygon-mainnet`.\n\n**Path B — Etherscan v2 unified** (fallback, if Alchemy path fails or key unset).\n\nSingle endpoint, all 50+ chains via `chainid`. Works keyless at lower rate limit.\n```bash\n# Append the key only when set, via .\u002Fsecretcurl's {ETHERSCAN_API_KEY} placeholder —\n# a bare $ETHERSCAN_API_KEY is refused by the Bash permission analyzer; keyless works.\nKEYQ=\"\"; [ -n \"${ETHERSCAN_API_KEY:+x}\" ] && KEYQ=\"&apikey={ETHERSCAN_API_KEY}\"\n# wallet\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=account&action=tokentx&address=${address}&startblock=${from_block}&endblock=99999999&sort=desc${KEYQ}\"\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=account&action=txlist&address=${address}&startblock=${from_block}&endblock=99999999&sort=desc${KEYQ}\"\n# contract\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=logs&action=getLogs&address=${address}&fromBlock=${from_block}&toBlock=latest${KEYQ}\"\n```\n\nChain → chainid: `ethereum=1`, `base=8453`, `arbitrum=42161`, `optimism=10`, `polygon=137`.\n\n**Fetch fallback.** Both Alchemy and Etherscan carry their key in the URL via `.\u002Fsecretcurl` (`{ALCHEMY_API_KEY}` \u002F `{ETHERSCAN_API_KEY}` placeholders), so if a call fails, retry the exact same URL via **WebFetch**. For POSTs, WebFetch accepts the JSON body.\n\nIf every path for a watch fails, mark the watch `fail` in the source footer and continue to the next — never abort the whole run.\n\n### 2. Decode every transfer\n\nRequired fields per event (normalised across Alchemy \u002F Etherscan payloads):\n\n| Field | Source |\n|-------|--------|\n| `tx_hash` | `hash` \u002F `txHash` |\n| `block_number`, `timestamp` | `blockNum` \u002F `metadata.blockTimestamp` |\n| `category` | `external_eth` \\| `erc20` \\| `erc721` \\| `erc1155` \\| `internal` \\| `log` |\n| `direction` | `in` if `to == watch`, else `out` |\n| `token.symbol`, `token.decimals` | Alchemy returns inline; for Etherscan, use `tokenSymbol`\u002F`tokenDecimal` fields |\n| `value_token` | human amount, e.g. `1,234,567.89 USDC` |\n| `value_usd` | `value_token × price_usd` (see step 3) |\n| `counterparty` | the non-watch address on the transfer |\n| `counterparty_label` | lookup in `known-addresses.yml`, else `null` |\n\n### 3. USD-enrich in one bulk call\n\nCollect distinct `(chain, token_contract)` pairs from decoded transfers. Bulk price via CoinGecko:\n\n```bash\nCGQ=\"\"; [ -n \"${COINGECKO_API_KEY:+x}\" ] && CGQ=\"&x_cg_demo_api_key={COINGECKO_API_KEY}\"\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.coingecko.com\u002Fapi\u002Fv3\u002Fsimple\u002Ftoken_price\u002F${chain}?contract_addresses=${joined}&vs_currencies=usd${CGQ}\"\n```\n\nNative ETH\u002FMATIC\u002Fetc. use `simple\u002Fprice?ids=ethereum,matic-network,...`. If CoinGecko is unreachable or returns no price for a token, set `value_usd = null` and tag the event `UNPRICED` — keep it in the log, drop it from the notification (can't meaningfully threshold without USD).\n\n### 4. Filter\n\nDrop an individual event if any of:\n- `value_usd \u003C threshold_usd` (watch config, default $1000)\n- `value_usd \u003C $0.10` (hard dust floor — prevents airdrop \u002F phishing spam)\n- `tx_hash` already present in this watch's `alerted_tx` (cross-run dedup)\n- `category == \"log\"` and watch has `event_topics:` and the topic0 is not in the list\n\n### 5. Categorize surviving events\n\nTag each event with one short label so the alert says *what kind of move it was*:\n\n| Tag | Condition |\n|-----|-----------|\n| `CEX-IN` \u002F `CEX-OUT` | counterparty label contains an exchange name (`Binance`, `Coinbase`, `Kraken`, `OKX`, `Bybit`, `Bitfinex`) |\n| `DEX-SWAP` | counterparty label contains a router (`Uniswap`, `1inch`, `Curve`, `Sushi`, `Aerodrome`, `CoWSwap`) |\n| `BRIDGE` | counterparty label contains a bridge (`Across`, `Stargate`, `Hop`, `Synapse`, `Wormhole`, `Celer`) |\n| `MINT` \u002F `BURN` | counterparty is `0x000…000` or the token contract itself |\n| `WHALE-TRANSFER` | `value_usd > 10 × median_usd_30d` for this watch |\n| `UNKNOWN-IN` \u002F `UNKNOWN-OUT` | fallback — based on direction |\n\nA single event can only carry one tag; pick by priority CEX > DEX > BRIDGE > MINT\u002FBURN > WHALE > UNKNOWN.\n\n### 6. Format the alert\n\nOne notification per run. Sort all surviving events globally by `value_usd` desc; group the output by watch label (watches with zero surviving events are omitted entirely). Lead with a one-sentence TL;DR naming the single biggest move.\n\n```\n*On-Chain Alert — ${today}*\nTL;DR: My Wallet sent $1.2M USDC to Binance 14 (biggest move on any watch in 30d).\n\n*My Wallet* (ethereum)\n• CEX-OUT $1.2M USDC → Binance 14 — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n• DEX-SWAP $42k WETH → USDC via Uniswap V3 Router — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n\n*Uniswap Pool* (ethereum)\n• WHALE-TRANSFER $850k WETH out → 0x9f...a1 — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n\n3 events on 2 watches | sources: alchemy=ok, coingecko=ok, etherscan=skipped | last_block→${block}\n```\n\nCap the notification body at 10 events; if more survived, append `+N more — see memory\u002Flogs\u002F${today}.md`. The `.\u002Fnotify` call should use the explorer URL for each chain (`etherscan.io`, `basescan.org`, `arbiscan.io`, `optimistic.etherscan.io`, `polygonscan.com`).\n\nSend the alert with `.\u002Fnotify -f alert.md`.\n\n### 7. Persist state and log\n\nFor each watch whose fetch **succeeded** (success ≠ \"events found\"):\n- `last_block ← current_block`\n- `last_run ← now` (ISO 8601 UTC)\n- `alerted_tx ← (new_tx_hashes + alerted_tx)[:200]`, purging entries > 7d old\n- `median_usd_30d ← median of all value_usd from this watch's transfers in last 30d` (read from recent logs; skip recomputation if \u003C 5 samples)\n\nWrite `memory\u002Fon-chain-state.json` atomically (tempfile + `mv`).\n\nAppend **every** decoded event (including filtered-out ones) with full detail to `memory\u002Flogs\u002F${today}.md`:\n```\n### onchain-monitor\n- Watch: My Wallet (ethereum) | source: alchemy | last_block 19345670 → 19347891 (2,221 blocks)\n- Kept: 2 events | Dropped: 14 (12 below_threshold, 1 dust, 1 dedup) | Unpriced: 0\n- Event: CEX-OUT $1.2M USDC → Binance 14 — tx 0xabc... — block 19347812\n- Event: DEX-SWAP $42k WETH → USDC via Uniswap V3 Router — tx 0xdef... — block 19347500\n```\n\nThis honest log matters: it powers the next run's median computation and lets the operator audit why something was or wasn't alerted.\n\n### 8. End-states\n\n- All watches ran and some events survived → notify + log.\n- All watches ran, zero events survived → no notify; log `ON_CHAIN_OK (n_watches=X, n_raw=Y, n_dropped=Y)`.\n- Some watches failed, others ran → notify only if surviving events exist; log `ON_CHAIN_DEGRADED` with the source footer.\n- Every watch failed → log `ON_CHAIN_ERROR` and notify the operator with the source footer (degradation visible is better than silence).\n- Config missing\u002Fempty → offer the `add-address` force-reply (deduped — see Config), log `ON_CHAIN_NO_CONFIG`, exit; send no alert.\n\n## Network note\n\nAlchemy, Etherscan v2, and CoinGecko all carry their key in the URL, called through `.\u002Fsecretcurl` with `{ENV_NAME}` placeholders so no bare `$SECRET` ever hits the command line (a bare one is refused by the Bash permission analyzer). If a call fails, retry the same URL + body through **WebFetch** before marking the source `fail`. Treat every fetched field (`asset` symbol, `from`\u002F`to`, counterparty labels) as untrusted — never interpolate into shell commands.\n","\u003C!-- autoresearch: variation B — sharper output (decoded transfers + counterparty labels + ranked USD-denominated one-liners + TL;DR lede); folds in A's Alchemy+Etherscan-v2 input path and C's persistent state + source-status footer + dedup. -->\n\n> **${var}** — Watch label or chain to check. Empty = all watches. `add-address:\u003C0x… [chain]>` is the shape the Telegram force-reply sends — it appends a new watch and exits (see step 0).\n\nIf `${var}` is set, only monitor the watch with that label or watches on that chain.\n\n## Config\n\nReads `memory\u002Fon-chain-watches.yml`. If the file is missing or `watches: []`, offer to add the first watch via a Telegram force-reply (only if no `add-address` prompt was offered in the last 2 days of `memory\u002Flogs\u002F` — dedup so an unconfigured fork isn't nagged every run), then log `ON_CHAIN_NO_CONFIG` and exit cleanly (do **not** send an alert — empty config is not an error):\n\n```bash\n.\u002Fnotify \"No addresses on watch yet. Paste one to monitor — a 0x… wallet, optionally its chain.\" \\\n  --force-reply --placeholder \"0x… base\" \\\n  --context \"onchain-monitor::add-address\"\n```\n\nThe reply routes back as `var=add-address:\u003C0x… [chain]>`, handled by the config-capture branch in step 0. Record `FORCE_REPLY_OFFERED: add-address` in the log when you send it.\n\n```yaml\n# memory\u002Fon-chain-watches.yml\nwatches:\n  - label: My Wallet\n    address: \"0x1234...abcd\"\n    chain: ethereum          # ethereum | base | arbitrum | optimism | polygon\n    type: wallet             # wallet | contract\n    threshold_usd: 1000      # alert on transfers ≥ this USD value (default 1000)\n  - label: Uniswap Pool\n    address: \"0xabcd...5678\"\n    chain: ethereum\n    type: contract\n    event_topics:            # optional — only alert on these topic0 hashes\n      - \"0xddf252ad...\"      # ERC20 Transfer\n```\n\nOptional `memory\u002Fknown-addresses.yml` — counterparty label dictionary used to humanize alerts. Lowercase keys, free-text values:\n```yaml\nlabels:\n  \"0x28c6c06298d514db089934071355e5743bf21d60\": \"Binance 14\"\n  \"0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43\": \"Coinbase 10\"\n  \"0xe592427a0aece92de3edee1f18e0157c05861564\": \"Uniswap V3 Router\"\n  \"0x0000000000000000000000000000000000000000\": \"Zero (mint\u002Fburn)\"\n```\n\n## State\n\n`memory\u002Fon-chain-state.json` — per-watch state, persisted atomically after each successful run:\n\n```json\n{\n  \"My Wallet\": {\n    \"last_block\": 19345678,\n    \"last_run\": \"2026-04-20T12:00:00Z\",\n    \"alerted_tx\": [\"0xabc...\", \"0xdef...\"],\n    \"median_usd_30d\": 8500\n  }\n}\n```\n\n- `last_block` — start block for the next run's fetch. Initialise to `current_block − 2400` (≈ 8h ETH) on first run.\n- `alerted_tx` — tx hashes alerted in last 7 days, capped at 200. Used for cross-run dedup.\n- `median_usd_30d` — rolling median USD size of transfers at this watch; powers the `WHALE-TRANSFER` tag.\n\nWrite the file via `mv` from a tempfile so a mid-run failure cannot corrupt state.\n\n## Steps\n\nRead `memory\u002FMEMORY.md`, `memory\u002Fon-chain-watches.yml`, `memory\u002Fon-chain-state.json`, and the last 2 days of `memory\u002Flogs\u002F` (for visibility only — state lives in the JSON file).\n\n### 0. Config capture (Telegram force-reply)\n\nBefore the per-watch loop, intercept the add-a-watch reply. When `${var}` starts with `add-address:`, the operator replied to the force-reply prompt (offered in the Config section on an empty config) — append a watch and **exit** (no monitoring this invocation). The remainder is `\u003Caddress> [chain]`:\n\n```bash\ncase \"${var}\" in\n  add-address:*)\n    REST=\"$(printf '%s' \"${var#add-address:}\" | sed 's\u002F^[[:space:]]*\u002F\u002F')\"\n    ADDR=\"$(printf '%s' \"$REST\" | awk '{print $1}')\"\n    CHAIN=\"$(printf '%s' \"$REST\" | awk '{print tolower($2)}')\"; CHAIN=\"${CHAIN:-ethereum}\"\n    case \"$CHAIN\" in ethereum|base|arbitrum|optimism|polygon) ;; *) CHAIN=ethereum ;; esac\n    if ! printf '%s' \"$ADDR\" | grep -qiE '^0x[0-9a-f]{40}$'; then\n      .\u002Fnotify \"Couldn't read \\\"$ADDR\\\" as an address. Reply with a 0x… wallet, optionally a chain.\"\n      exit 0\n    fi\n    mkdir -p memory; touch memory\u002Fon-chain-watches.yml\n    # Normalize an empty inline list so we can append block items, and ensure a watches: key exists.\n    sed -i.bak -E 's\u002F^watches:[[:space:]]*\\[\\][[:space:]]*$\u002Fwatches:\u002F' memory\u002Fon-chain-watches.yml && rm -f memory\u002Fon-chain-watches.yml.bak\n    grep -q '^watches:' memory\u002Fon-chain-watches.yml || printf 'watches:\\n' >> memory\u002Fon-chain-watches.yml\n    if grep -qi \"$ADDR\" memory\u002Fon-chain-watches.yml; then\n      .\u002Fnotify \"Already watching ${ADDR}.\"\n    else\n      SHORT=\"$(printf '%s' \"$ADDR\" | sed -E 's\u002F^(0x.{4}).*(.{4})$\u002F\\1…\\2\u002F')\"\n      cat >> memory\u002Fon-chain-watches.yml \u003C\u003CEOF\n  - label: \"$SHORT\"\n    address: \"$ADDR\"\n    chain: $CHAIN\n    type: wallet\n    threshold_usd: 1000\nEOF\n      .\u002Fnotify \"Now watching ${SHORT} on ${CHAIN} (wallet, moves ≥\\$1000). Edit memory\u002Fon-chain-watches.yml to tune.\"\n    fi\n    # log under ### onchain-monitor: - view: add-address (var=\"${var}\") → $ADDR on $CHAIN\n    exit 0 ;;\nesac\n```\n\nDefaults for a captured watch: `type: wallet`, `threshold_usd: 1000`, `label` = the shortened address. The operator refines chain\u002Ftype\u002Fthreshold by editing `memory\u002Fon-chain-watches.yml` directly. (This appends to the end of the file, which is correct because `watches:` is the only top-level key — if a future config grows more keys, insert under `watches:` instead of at EOF.)\n\nFor each watch (filtered by `${var}`):\n\n### 1. Fetch raw activity from `last_block` → latest\n\n**Path A — Alchemy** (preferred, if `ALCHEMY_API_KEY` set).\n\nWallets use `alchemy_getAssetTransfers` — one call returns categorized in\u002Fout history with `value`, `asset`, `category`, `hash`, `from`, `to`, `metadata.blockTimestamp`. Run it twice per watch (once with `toAddress`, once with `fromAddress`) and merge.\n\n```bash\n.\u002Fsecretcurl -m 10 -s -X POST \"https:\u002F\u002F${network}.g.alchemy.com\u002Fv2\u002F{ALCHEMY_API_KEY}\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"alchemy_getAssetTransfers\",\"params\":[{\n    \"fromBlock\":\"0x'${from_block_hex}'\",\n    \"toAddress\":\"'${address}'\",\n    \"category\":[\"external\",\"internal\",\"erc20\",\"erc721\",\"erc1155\"],\n    \"withMetadata\":true,\"excludeZeroValue\":true,\"maxCount\":\"0x32\"\n  }]}'\n```\n\nContracts use `eth_getLogs` against the same Alchemy URL (Alchemy accepts up to ~10k block ranges).\n\nChain → network slug: `ethereum=eth-mainnet`, `base=base-mainnet`, `arbitrum=arb-mainnet`, `optimism=opt-mainnet`, `polygon=polygon-mainnet`.\n\n**Path B — Etherscan v2 unified** (fallback, if Alchemy path fails or key unset).\n\nSingle endpoint, all 50+ chains via `chainid`. Works keyless at lower rate limit.\n```bash\n# Append the key only when set, via .\u002Fsecretcurl's {ETHERSCAN_API_KEY} placeholder —\n# a bare $ETHERSCAN_API_KEY is refused by the Bash permission analyzer; keyless works.\nKEYQ=\"\"; [ -n \"${ETHERSCAN_API_KEY:+x}\" ] && KEYQ=\"&apikey={ETHERSCAN_API_KEY}\"\n# wallet\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=account&action=tokentx&address=${address}&startblock=${from_block}&endblock=99999999&sort=desc${KEYQ}\"\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=account&action=txlist&address=${address}&startblock=${from_block}&endblock=99999999&sort=desc${KEYQ}\"\n# contract\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.etherscan.io\u002Fv2\u002Fapi?chainid=${chainid}&module=logs&action=getLogs&address=${address}&fromBlock=${from_block}&toBlock=latest${KEYQ}\"\n```\n\nChain → chainid: `ethereum=1`, `base=8453`, `arbitrum=42161`, `optimism=10`, `polygon=137`.\n\n**Fetch fallback.** Both Alchemy and Etherscan carry their key in the URL via `.\u002Fsecretcurl` (`{ALCHEMY_API_KEY}` \u002F `{ETHERSCAN_API_KEY}` placeholders), so if a call fails, retry the exact same URL via **WebFetch**. For POSTs, WebFetch accepts the JSON body.\n\nIf every path for a watch fails, mark the watch `fail` in the source footer and continue to the next — never abort the whole run.\n\n### 2. Decode every transfer\n\nRequired fields per event (normalised across Alchemy \u002F Etherscan payloads):\n\n| Field | Source |\n|-------|--------|\n| `tx_hash` | `hash` \u002F `txHash` |\n| `block_number`, `timestamp` | `blockNum` \u002F `metadata.blockTimestamp` |\n| `category` | `external_eth` \\| `erc20` \\| `erc721` \\| `erc1155` \\| `internal` \\| `log` |\n| `direction` | `in` if `to == watch`, else `out` |\n| `token.symbol`, `token.decimals` | Alchemy returns inline; for Etherscan, use `tokenSymbol`\u002F`tokenDecimal` fields |\n| `value_token` | human amount, e.g. `1,234,567.89 USDC` |\n| `value_usd` | `value_token × price_usd` (see step 3) |\n| `counterparty` | the non-watch address on the transfer |\n| `counterparty_label` | lookup in `known-addresses.yml`, else `null` |\n\n### 3. USD-enrich in one bulk call\n\nCollect distinct `(chain, token_contract)` pairs from decoded transfers. Bulk price via CoinGecko:\n\n```bash\nCGQ=\"\"; [ -n \"${COINGECKO_API_KEY:+x}\" ] && CGQ=\"&x_cg_demo_api_key={COINGECKO_API_KEY}\"\n.\u002Fsecretcurl -m 10 -s \"https:\u002F\u002Fapi.coingecko.com\u002Fapi\u002Fv3\u002Fsimple\u002Ftoken_price\u002F${chain}?contract_addresses=${joined}&vs_currencies=usd${CGQ}\"\n```\n\nNative ETH\u002FMATIC\u002Fetc. use `simple\u002Fprice?ids=ethereum,matic-network,...`. If CoinGecko is unreachable or returns no price for a token, set `value_usd = null` and tag the event `UNPRICED` — keep it in the log, drop it from the notification (can't meaningfully threshold without USD).\n\n### 4. Filter\n\nDrop an individual event if any of:\n- `value_usd \u003C threshold_usd` (watch config, default $1000)\n- `value_usd \u003C $0.10` (hard dust floor — prevents airdrop \u002F phishing spam)\n- `tx_hash` already present in this watch's `alerted_tx` (cross-run dedup)\n- `category == \"log\"` and watch has `event_topics:` and the topic0 is not in the list\n\n### 5. Categorize surviving events\n\nTag each event with one short label so the alert says *what kind of move it was*:\n\n| Tag | Condition |\n|-----|-----------|\n| `CEX-IN` \u002F `CEX-OUT` | counterparty label contains an exchange name (`Binance`, `Coinbase`, `Kraken`, `OKX`, `Bybit`, `Bitfinex`) |\n| `DEX-SWAP` | counterparty label contains a router (`Uniswap`, `1inch`, `Curve`, `Sushi`, `Aerodrome`, `CoWSwap`) |\n| `BRIDGE` | counterparty label contains a bridge (`Across`, `Stargate`, `Hop`, `Synapse`, `Wormhole`, `Celer`) |\n| `MINT` \u002F `BURN` | counterparty is `0x000…000` or the token contract itself |\n| `WHALE-TRANSFER` | `value_usd > 10 × median_usd_30d` for this watch |\n| `UNKNOWN-IN` \u002F `UNKNOWN-OUT` | fallback — based on direction |\n\nA single event can only carry one tag; pick by priority CEX > DEX > BRIDGE > MINT\u002FBURN > WHALE > UNKNOWN.\n\n### 6. Format the alert\n\nOne notification per run. Sort all surviving events globally by `value_usd` desc; group the output by watch label (watches with zero surviving events are omitted entirely). Lead with a one-sentence TL;DR naming the single biggest move.\n\n```\n*On-Chain Alert — ${today}*\nTL;DR: My Wallet sent $1.2M USDC to Binance 14 (biggest move on any watch in 30d).\n\n*My Wallet* (ethereum)\n• CEX-OUT $1.2M USDC → Binance 14 — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n• DEX-SWAP $42k WETH → USDC via Uniswap V3 Router — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n\n*Uniswap Pool* (ethereum)\n• WHALE-TRANSFER $850k WETH out → 0x9f...a1 — [tx](https:\u002F\u002Fetherscan.io\u002Ftx\u002F0x...)\n\n3 events on 2 watches | sources: alchemy=ok, coingecko=ok, etherscan=skipped | last_block→${block}\n```\n\nCap the notification body at 10 events; if more survived, append `+N more — see memory\u002Flogs\u002F${today}.md`. The `.\u002Fnotify` call should use the explorer URL for each chain (`etherscan.io`, `basescan.org`, `arbiscan.io`, `optimistic.etherscan.io`, `polygonscan.com`).\n\nSend the alert with `.\u002Fnotify -f alert.md`.\n\n### 7. Persist state and log\n\nFor each watch whose fetch **succeeded** (success ≠ \"events found\"):\n- `last_block ← current_block`\n- `last_run ← now` (ISO 8601 UTC)\n- `alerted_tx ← (new_tx_hashes + alerted_tx)[:200]`, purging entries > 7d old\n- `median_usd_30d ← median of all value_usd from this watch's transfers in last 30d` (read from recent logs; skip recomputation if \u003C 5 samples)\n\nWrite `memory\u002Fon-chain-state.json` atomically (tempfile + `mv`).\n\nAppend **every** decoded event (including filtered-out ones) with full detail to `memory\u002Flogs\u002F${today}.md`:\n```\n### onchain-monitor\n- Watch: My Wallet (ethereum) | source: alchemy | last_block 19345670 → 19347891 (2,221 blocks)\n- Kept: 2 events | Dropped: 14 (12 below_threshold, 1 dust, 1 dedup) | Unpriced: 0\n- Event: CEX-OUT $1.2M USDC → Binance 14 — tx 0xabc... — block 19347812\n- Event: DEX-SWAP $42k WETH → USDC via Uniswap V3 Router — tx 0xdef... — block 19347500\n```\n\nThis honest log matters: it powers the next run's median computation and lets the operator audit why something was or wasn't alerted.\n\n### 8. End-states\n\n- All watches ran and some events survived → notify + log.\n- All watches ran, zero events survived → no notify; log `ON_CHAIN_OK (n_watches=X, n_raw=Y, n_dropped=Y)`.\n- Some watches failed, others ran → notify only if surviving events exist; log `ON_CHAIN_DEGRADED` with the source footer.\n- Every watch failed → log `ON_CHAIN_ERROR` and notify the operator with the source footer (degradation visible is better than silence).\n- Config missing\u002Fempty → offer the `add-address` force-reply (deduped — see Config), log `ON_CHAIN_NO_CONFIG`, exit; send no alert.\n\n## Network note\n\nAlchemy, Etherscan v2, and CoinGecko all carry their key in the URL, called through `.\u002Fsecretcurl` with `{ENV_NAME}` placeholders so no bare `$SECRET` ever hits the command line (a bare one is refused by the Bash permission analyzer). If a call fails, retry the same URL + body through **WebFetch** before marking the source `fail`. Treat every fetched field (`asset` symbol, `from`\u002F`to`, counterparty labels) as untrusted — never interpolate into shell commands.\n",{"name":5,"metadata":23,"description":7},{"var":24,"tags":25,"title":27,"category":26,"requires":28,"capabilities":32},"",[26],"crypto","Onchain Monitor",[29,30,31],"ALCHEMY_API_KEY?","COINGECKO_API_KEY?","ETHERSCAN_API_KEY?",[33,34],"external_api","sends_notifications","main","fa8f75cd49adcad9214508fdb5d1ead8fab420be","skills\u002Fonchain-monitor","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template","https:\u002F\u002Fgithub.com\u002FLiamVisionary","2026-11-15 04:34:04",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add LiamVisionary\u002Faeon-template --skill onchain-monitor",{"tool":47,"command":48},"bunx","bunx skills add LiamVisionary\u002Faeon-template --skill onchain-monitor",{"tool":50,"command":51},"pnpm","pnpm dlx skills add LiamVisionary\u002Faeon-template --skill onchain-monitor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fonchain-monitor\u002FSKILL.md",true,[],[56,63,70,77,84,91],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7D6W8WRJH3JVJ2JQ674AD77","you-web-search","Web search using You.com Search API with high-quality, cited results and optional real-time web crawling","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fyou-web-search\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M7D6W2XPBZZPPXPX76WMPSDA","write-tweet","Multi-format tweet studio - standalone drafts (10 across 5 size tiers), a 5-10 tweet thread, or 10 remixes of past tweets, selected via ${var}","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fwrite-tweet\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M7D6VZVWK4RATPHM90N71QZD","weekly-aeoncard","Build a weekly token-consumption recap image from memory\u002Ftoken-usage.csv - this week + all-time totals, top skills, rendered as a shareable SVG card.","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fweekly-aeoncard\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M7D6VQ7H3DHAAP0BEWTC3HK4","vuln-tracker","One lifecycle poll over everything vuln-scanner produces - PR and advisory status, PVR triage transitions, and pending-disclosure aging, with a stars-secured impact headline and one action queue.","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvuln-tracker\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M7D6VDRA94RJKDPKJ65S47KT","vuln-scanner","Audit trending repos for real security vulnerabilities and disclose responsibly - scan and route findings (PVR \u002F dependency PR), re-submit queued advisories, and send armed email disclosures","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvuln-scanner\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":18},"01M7D6V8BNPHCTPJBJD89H8DZF","video-script","Turn a repo, product page, or update into a recording-ready video script in a receipts-first format - verifies every claim against live sources, then writes timestamped VO + on-screen direction with a plain-language glossary, assets checklist, anti-tells, and a verify-before-recording list","https:\u002F\u002Fgithub.com\u002FLiamVisionary\u002Faeon-template\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-script\u002FSKILL.md",[],[]]