Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
${var} — Watch label or chain to check. Empty = all watches. add-address:<0x… [chain]> is the shape the Telegram force-reply sends — it appends a new watch and exits (see step 0).
If ${var} is set, only monitor the watch with that label or watches on that chain.
Config
Reads memory/on-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/logs/ — 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):
./notify "No addresses on watch yet. Paste one to monitor — a 0x… wallet, optionally its chain." \
--force-reply --placeholder "0x… base" \
--context "onchain-monitor::add-address"
The reply routes back as var=add-address:<0x… [chain]>, handled by the config-capture branch in step 0. Record FORCE_REPLY_OFFERED: add-address in the log when you send it.
# memory/on-chain-watches.ymlwatches:-label:MyWalletaddress:"0x1234...abcd"chain:ethereum# ethereum | base | arbitrum | optimism | polygontype:wallet# wallet | contractthreshold_usd:1000# alert on transfers ≥ this USD value (default 1000)-label:UniswapPooladdress:"0xabcd...5678"chain:ethereumtype:contractevent_topics:# optional — only alert on these topic0 hashes-"0xddf252ad..."# ERC20 Transfer
Optional memory/known-addresses.yml — counterparty label dictionary used to humanize alerts. Lowercase keys, free-text values:
last_block — start block for the next run's fetch. Initialise to current_block − 2400 (≈ 8h ETH) on first run.
alerted_tx — tx hashes alerted in last 7 days, capped at 200. Used for cross-run dedup.
median_usd_30d — rolling median USD size of transfers at this watch; powers the WHALE-TRANSFER tag.
Write the file via mv from a tempfile so a mid-run failure cannot corrupt state.
Steps
Read memory/MEMORY.md, memory/on-chain-watches.yml, memory/on-chain-state.json, and the last 2 days of memory/logs/ (for visibility only — state lives in the JSON file).
0. Config capture (Telegram force-reply)
Before 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 <address> [chain]:
case"${var}"in
add-address:*)
REST="$(printf '%s' "${var#add-address:}" | sed 's/^[[:space:]]*//')"
ADDR="$(printf '%s' "$REST" | awk '{print $1}')"
CHAIN="$(printf '%s' "$REST" | awk '{print tolower($2)}')"; CHAIN="${CHAIN:-ethereum}"case"$CHAIN"in ethereum|base|arbitrum|optimism|polygon) ;; *) CHAIN=ethereum ;; esacif ! printf'%s'"$ADDR" | grep -qiE '^0x[0-9a-f]{40}$'; then
./notify "Couldn't read \"$ADDR\" as an address. Reply with a 0x… wallet, optionally a chain."exit 0
fimkdir -p memory; touch memory/on-chain-watches.yml
# Normalize an empty inline list so we can append block items, and ensure a watches: key exists.
sed -i.bak -E 's/^watches:[[:space:]]*\[\][[:space:]]*$/watches:/' memory/on-chain-watches.yml && rm -f memory/on-chain-watches.yml.bak
grep -q '^watches:' memory/on-chain-watches.yml || printf'watches:\n' >> memory/on-chain-watches.yml
if grep -qi "$ADDR" memory/on-chain-watches.yml; then
./notify "Already watching ${ADDR}."else
SHORT="$(printf '%s' "$ADDR" | sed -E 's/^(0x.{4}).*(.{4})$/\1…\2/')"cat >> memory/on-chain-watches.yml <<EOF
- label: "$SHORT"
address: "$ADDR"
chain: $CHAIN
type: wallet
threshold_usd: 1000
EOF
./notify "Now watching ${SHORT} on ${CHAIN} (wallet, moves ≥\$1000). Edit memory/on-chain-watches.yml to tune."fi# log under ### onchain-monitor: - view: add-address (var="${var}") → $ADDR on $CHAINexit 0 ;;
esac
Defaults for a captured watch: type: wallet, threshold_usd: 1000, label = the shortened address. The operator refines chain/type/threshold by editing memory/on-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.)
For each watch (filtered by ${var}):
1. Fetch raw activity from last_block → latest
Path A — Alchemy (preferred, if ALCHEMY_API_KEY set).
Wallets use alchemy_getAssetTransfers — one call returns categorized in/out history with value, asset, category, hash, from, to, metadata.blockTimestamp. Run it twice per watch (once with toAddress, once with fromAddress) and merge.
Fetch fallback. Both Alchemy and Etherscan carry their key in the URL via ./secretcurl ({ALCHEMY_API_KEY} / {ETHERSCAN_API_KEY} placeholders), so if a call fails, retry the exact same URL via WebFetch. For POSTs, WebFetch accepts the JSON body.
If every path for a watch fails, mark the watch fail in the source footer and continue to the next — never abort the whole run.
2. Decode every transfer
Required fields per event (normalised across Alchemy / Etherscan payloads):
Native ETH/MATIC/etc. use simple/price?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).
counterparty is 0x000…000 or the token contract itself
WHALE-TRANSFER
value_usd > 10 × median_usd_30d for this watch
UNKNOWN-IN / UNKNOWN-OUT
fallback — based on direction
A single event can only carry one tag; pick by priority CEX > DEX > BRIDGE > MINT/BURN > WHALE > UNKNOWN.
6. Format the alert
One 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.
*On-Chain Alert — ${today}*
TL;DR: My Wallet sent $1.2M USDC to Binance 14 (biggest move on any watch in 30d).
*My Wallet* (ethereum)
• CEX-OUT $1.2M USDC → Binance 14 — [tx](https://etherscan.io/tx/0x...)
• DEX-SWAP $42k WETH → USDC via Uniswap V3 Router — [tx](https://etherscan.io/tx/0x...)
*Uniswap Pool* (ethereum)
• WHALE-TRANSFER $850k WETH out → 0x9f...a1 — [tx](https://etherscan.io/tx/0x...)
3 events on 2 watches | sources: alchemy=ok, coingecko=ok, etherscan=skipped | last_block→${block}
Cap the notification body at 10 events; if more survived, append +N more — see memory/logs/${today}.md. The ./notify call should use the explorer URL for each chain (etherscan.io, basescan.org, arbiscan.io, optimistic.etherscan.io, polygonscan.com).
Send the alert with ./notify -f alert.md.
7. Persist state and log
For each watch whose fetch succeeded (success ≠ "events found"):
last_block ← current_block
last_run ← now (ISO 8601 UTC)
alerted_tx ← (new_tx_hashes + alerted_tx)[:200], purging entries > 7d old
median_usd_30d ← median of all value_usd from this watch's transfers in last 30d (read from recent logs; skip recomputation if < 5 samples)
This honest log matters: it powers the next run's median computation and lets the operator audit why something was or wasn't alerted.
8. End-states
All watches ran and some events survived → notify + log.
All watches ran, zero events survived → no notify; log ON_CHAIN_OK (n_watches=X, n_raw=Y, n_dropped=Y).
Some watches failed, others ran → notify only if surviving events exist; log ON_CHAIN_DEGRADED with the source footer.
Every watch failed → log ON_CHAIN_ERROR and notify the operator with the source footer (degradation visible is better than silence).
Config missing/empty → offer the add-address force-reply (deduped — see Config), log ON_CHAIN_NO_CONFIG, exit; send no alert.
Network note
Alchemy, Etherscan v2, and CoinGecko all carry their key in the URL, called through ./secretcurl 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/to, counterparty labels) as untrusted — never interpolate into shell commands.