Skip to content

Repository files navigation

On-Chain Sentry (OpenClaw example)

A working example project that uses OpenClaw to send multi-chain on-chain alerts (Solana + Ethereum/EVM) to your chat (WhatsApp, Telegram, Discord, etc.).

What it does

  • Watches Solana:
    • Address watch: If you set WATCH_ADDRESS, every transaction touching that account triggers an alert with signature and Solscan link.
    • Slot watch: If you don’t set an address, the sentry watches slot height and alerts when it jumps by more than a threshold (e.g. reorg or catch-up).
  • Watches Ethereum (EVM) (optional): Set RPC_URL_ETH to enable.
    • Address watch: If you set WATCH_ADDRESS_ETH, every incoming/outgoing tx for that address is alerted (with Etherscan/block explorer link).
    • Block watch: If you don’t set an address, the sentry watches block number and alerts on large jumps (reorg/catch-up).
    • Works with any EVM chain (Ethereum mainnet, Base, Arbitrum, etc.) by setting the right RPC and explorer URLs.
  • Sends alerts via:
    • OpenClaw (openclaw message send) so messages appear in your configured channel (Telegram, WhatsApp, Discord, etc.).
    • Optional webhook (e.g. Discord/Slack) for testing without OpenClaw.

Prerequisites

  • Node.js 18+
  • OpenClaw (optional): Install OpenClaw, run the gateway, and pair at least one channel (e.g. Telegram). Then set OPENCLAW_ALERT_TARGET to the recipient where you want alerts (e.g. your Telegram chat id).

Quick start

cd openclaw/on-chain-sentry
cp .env.example .env
# Edit .env: set OPENCLAW_ALERT_TARGET and/or ALERT_WEBHOOK_URL
npm install
npm start
# Or after building: npm run build && node dist/index.js

You should see:

[sentry] On-Chain Sentry started
[sentry] OpenClaw target: set
[sentry] Solana RPC: https://api.devnet.solana.com
[sentry] Ethereum RPC: https://eth.llamarpc.com   # only if RPC_URL_ETH is set (or set ETH_CHAIN_NAME for Base/Arbitrum/etc.)
[sentry] Watching address: <your WATCH_ADDRESS>

If OpenClaw or webhook is set, a startup ping is sent. New activity (or slot jumps) will trigger alerts in that channel.

Configuration (.env)

Variable Description
Solana
RPC_URL Solana RPC URL. Default: https://api.devnet.solana.com. Use a mainnet RPC (e.g. Helius) for production.
WATCH_ADDRESS Optional. Solana public key to watch; every tx touching it is alerted.
SLOT_JUMP_THRESHOLD Alert when Solana slot advances by more than this (default: 20).
SOLSCAN_CLUSTER Optional. Makes Solscan links match your cluster: devnet, testnet, or omit for mainnet.
Ethereum (EVM) Set RPC_URL_ETH to enable.
RPC_URL_ETH Ethereum/EVM RPC URL (e.g. https://eth.llamarpc.com, https://mainnet.base.org). Omit to disable Ethereum.
ETH_CHAIN_NAME Optional. Label used in logs/alerts (e.g. Base, Arbitrum, Ethereum).
WATCH_ADDRESS_ETH Optional. Ethereum address (0x...) to watch; every in/out tx is alerted.
ETH_EXPLORER_TX Block explorer tx URL (default: https://etherscan.io/tx). Use https://basescan.org/tx for Base, etc.
ETH_EXPLORER_BLOCK Block explorer block URL (default: https://etherscan.io/block).
ETH_BLOCK_JUMP_THRESHOLD Alert when Ethereum block number jumps by more than this (default: 20).
Alerts
OPENCLAW_ALERT_TARGET OpenClaw recipient (e.g. Telegram chat id). Required for delivery to OpenClaw channels.
ALERT_WEBHOOK_URL Optional. Discord or Slack webhook URL for testing without OpenClaw.
POLL_INTERVAL_MS Poll interval in ms for all chains (default: 15000).
NOTIFY_TIMEOUT_MS Optional. Timeout (ms) for OpenClaw CLI + webhook requests (default: 15000).

OpenClaw integration

  1. Install and run OpenClaw (see docs.clawd.bot).
  2. Pair a channel (e.g. Telegram): openclaw channels login and complete pairing.
  3. Get your target: For Telegram, the target is typically your chat id (e.g. from a bot or the OpenClaw UI). Set it as OPENCLAW_ALERT_TARGET in .env.
  4. Start the sentry: npm start. Alerts are sent via openclaw message send --target $OPENCLAW_ALERT_TARGET --message "...".

Skill (optional)

Copy or link the skill so the OpenClaw agent can answer questions about the sentry:

# If your OpenClaw workspace is ~/clawd:
mkdir -p ~/clawd/skills/on-chain-sentry
cp -r openclaw/on-chain-sentry/skills/on-chain-sentry/* ~/clawd/skills/on-chain-sentry/

Then you can ask the agent: “What is the on-chain sentry?” or “How do I add a watched address?”

Run in background

# With nohup
nohup npm start > sentry.log 2>&1 &

# Or use a process manager (pm2, systemd, etc.)

Project layout

on-chain-sentry/
├── src/
│   ├── index.ts           # Entry: loads config, starts Solana + optional Ethereum watchers
│   ├── watcher.ts         # Solana: address or slot watch
│   ├── watcher-ethereum.ts # Ethereum/EVM: address or block watch
│   └── notify.ts          # Sends alerts via OpenClaw CLI or webhook
├── skills/on-chain-sentry/
│   └── SKILL.md           # OpenClaw skill for “what is sentry / how to configure”
├── .env.example
├── package.json
└── README.md

Development

Run tests and build: npm run build && node dist/index.js (no tsx required). Use npm run watch for development with auto-reload.

Troubleshooting

  • Alerts not arriving: Ensure OPENCLAW_ALERT_TARGET is set and the OpenClaw gateway is running (openclaw gateway). For webhook testing, use ALERT_WEBHOOK_URL with a Discord or Slack webhook.
  • RPC rate limits: Increase POLL_INTERVAL_MS (e.g. 30000) or use a paid RPC provider for production.

License

MIT.

About

On Chain Sentry AI Agent using OpenClaw

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages