ChainWatch ASP is a production-style, off-chain evaluation backend that models how an Association Set Provider (ASP) processes on-chain events and produces compliance decisions.
It demonstrates how smart contract events can be ingested, evaluated against risk rules, and converted into enforceable eligibility decisions:
Smart Contract → Watcher → ASP Backend → Rule Engine → Decision Store → Eligibility Guard
This project simulates the compliance and risk layer of a privacy-aware protocol.
It implements:
- On-chain event ingestion via watcher
- Asynchronous evaluation pipeline
- Deterministic rule engine (deny > flag > allow)
- Persistent decision storage
- Admin-managed policy layer
- Eligibility enforcement API
This is not just CRUD — it is an event-driven compliance backend.
- Listens to smart contract events via
ethers.js - Automatically forwards structured events to
POST /events - Runs independently from API server
POST /events
- Stores event in Postgres
- Enforces idempotency using
(tx_hash, log_index) - Dispatches asynchronous evaluation
Each event is evaluated against modular rules:
sanctionsRule→ deny blocked sendersamountRule→ flag high-value depositsvelocityRule→ flag abnormal frequency
Priority resolution:
deny > flag > allow
All rules run; final decision is deterministic and auditable.
Events and decisions are persisted:
eventsdecisionsblocked_addresses
Schema managed via node-pg-migrate.
GET /eligibility/:eventId
Used by relayers, frontends, or middleware before allowing sensitive actions.
Example response:
{
"eligible": false,
"status": "deny",
"reason": "sender is blocked"
}This simulates how compliance decisions are enforced off-chain.
POST /admin/block-address
Allows operators to manage blocked addresses.
Policy updates directly affect evaluation outcomes.
Start API server:
npm run dev
Start watcher worker:
npm run watcher
- Clean separation: controllers → services → repositories → rules
- Async evaluation via dispatcher
- Idempotent event ingestion
- Modular, extensible rule engine
- Clear enforcement boundary (eligibility API)
- Worker + API process separation
- Audit-ready decision storage
This project models real-world off-chain compliance systems used in:
- Privacy infrastructure
- Risk evaluation pipelines
- Relayer-based architectures
- Policy-driven transaction filtering