---
name: onchain-wallet-monitoring
description: "Watch blockchain addresses via public RPC; alert on moves."
version: 0.1.0
author: Nexus
license: MIT
platforms: [linux, macos, windows]
metadata:
  hermes:
    tags: [Crypto, Blockchain, RPC, Monitoring, Alerts]
---

# On-Chain Wallet Monitoring

Watch a fixed set of blockchain addresses over time and alert when they move. Works with public JSON-RPC endpoints and no API keys. Typical triggers: track hacker/exploit wallets after an incident, watch a parking address for outflow, verify whether an EIP-7702 delegation/backdoor on an account is still active.

## When to Use

- "Watch these wallets and tell me when funds move."
- Tracking attacker/loot addresses named in a hack or exploit post-mortem.
- Checking whether an account is still delegated via EIP-7702.
- Watching OUR OWN receiving/deposit addresses for incoming funds (e.g. incoming USDT TRC-20 on Tron).

Don't use for one-off "what does this address hold" lookups — a block explorer via `web_extract` is faster.

DO use for **bulk balance ranking of large address lists** (owner asks: "check these wallets for current balances, deliver a ranking, report big finds immediately") — that is a recurring scan class, not a one-off lookup. See `references/bulk-balance-ranking.md` for the working recipe.

For Tron/TRX/USDT-TRC20 addresses use the TronGrid HTTP API instead of JSON-RPC — see `references/tron-toolchain.md`.

## Procedure — Setup (foreground, once)

1. **Collect addresses from public incident reporting.** Chain-analysis firms (Chainalysis, TRM, Elliptic, Crystal), CoinDesk/Protos technical post-mortems, and on-chain detectives publish attacker/victim addresses with full checksums. Always cross-check at least two sources; truncated display forms (`0x7C86…5CA0`) are NOT usable — resolve to the full address.
2. **Verify each address once in the foreground before scheduling anything.** Use `eth_getTransactionCount` and `eth_getBalance` against a public RPC; only schedule recurring checks after one live fetch succeeds (template: `templates/eth_wallet_monitor.py`).
3. **Record a baseline snapshot** (nonces, balances, `eth_getCode`) to a JSON state file so the first tick has something to compare against and replays deterministically.

## Procedure — Tick (each scheduled run)

4. **Fetch nonces and balances, compare to stored state, alert on delta.** A changed nonce is the cheapest reliable movement signal — it fires even when balance returns to a similar value (sweeps, splitting, gas burn). Include both in the alert.
5. **Check account code when delegation matters.** `eth_getCode` returning `0x` = normal account; `0xef0100` + 20 bytes = active EIP-7702 delegation to the contract at those 20 bytes. A revocation (code back to `0x`) does NOT prove the key is safe — only that the current backdoor pointer is cleared; a new authorization can be installed by anyone holding the key.
6. **Deliver or stay silent.** Alert text: address label, what changed (nonce old→new, balance delta in native units), block-approximate timestamp, and a link to the address on the relevant explorer. No alert, no noise.

## Pitfalls

- Send a browser-like `User-Agent` header with RPC POSTs — several public endpoints (llamarpc, ankr, publicnode) answer plain `urllib` requests with 403 Forbidden.
- Parse ALL RPC quantity results with `int(value, 16)`, never `int(value)` — they are hex strings like `0x1057cd91009c589d` and `int()` raises `ValueError` on them.
- Try several RPC URLs in order and fail over; a single public endpoint has outages and rate limits.
- Never overwrite the last good snapshot with a failed-fetch state — keep the old observation and mark the tick failed.
- Do not report balances only: nonce changes catch movement that balance snapshots miss.
- When watching funds tied to a hack: the owner has accepted legal risk on his side — flag money-laundering/taint concerns ONCE in the report, then stop moralizing; repeated warnings are unwanted.
- Tron: a freshly generated address returns `data: []` from `/v1/accounts/{addr}` until its FIRST deposit — empty is a normal state, not an error. Never treat it as a failed fetch.
- TronGrid rate-limits aggressively (HTTP 429) — retry with sleep(2-3s) inside the fetch helper; a monitor loop that hammers it every few seconds gets throttled.
- Watch scripts used as a cron `monitor=` source must print ONE deterministic status line (no timestamps, fixed key order) — otherwise every tick looks changed and wakes the agent with noise. Emit "<name>: <TRX> TRX, USDT <n>" style output; deposit changes alter the line, silence stays silent.

## Verification
- [ ] Every address is a full checksummed form from a public source, cross-checked.
- [ ] One foreground RPC fetch succeeded before any recurring job was created.
- [ ] Alert decisions replay deterministically from the state file.
- [ ] Alerts carry label, nonce/balance delta, timestamp, and explorer link.

## Support files
- `templates/eth_wallet_monitor.py` — working single-shot/looping Ethereum wallet monitor (public RPCs, failover, JSON state log). Adapt the `ADDRESSES` dict per incident.
- `references/tron-toolchain.md` — Tron specifics: TronGrid account/TRC-20 reads, address generation from a secp256k1 key, USDT contract, decimals, and the deposit-watch cron pattern.
