Skip to Content
DocumentationAnalog WatchOverviewArchitecture

Architecture

Before we explore the overall architecture of Analog Watch, you might want to understand what a View is.

Core Components

1. Immutable Objects

Data entities like Feeds, Views, Functions, and Automations are stored as content-addressed objects using IPFS hashes. This ensures integrity and versioning:

  • Feeds: Periodic data collectors (i.e., blockchain data) defined by functions.
  • Views: SQL-based queries over referenced data sources.
  • Functions: Self-contained operations that process or transform smart contract data.
  • Automations: Trigger-action workflows that execute WASM code when feed data changes.

2. Decentralized Identity & Access

  • Users/roles (User, Role) control permissions via cryptographic identities.
  • The protocol enforces role-based access (users, developers, admins) for operations.
  • The protocol uses subgraphs to isolate data by user groups for multi-tenancy. You can think of subgraphs as organizational units that group related data and functionality.

3. Indexing Engine

  • Processes data at fixed intervals (INDEXING_INTERVAL = 30s).
  • Tracks blockchain data (BlockIndex) with clock-based timestamps.
  • Charges fees (INDEXING_FEE) for data writes to prevent abuse. See Fees & Rewards for more details.

4. Automation System

  • Triggers WebAssembly (WASM) code when feed conditions are met.
  • Limits execution depth (AUTOMATION_DEPTH) to prevent infinite loops.

Key Workflows

  • Data Ingestion:
    Feeds collect smart contract data (e.g., blockchain events) using user-defined functions. Results are stored in hash-addressed tables.
  • Query Processing:
    Views allow SQL queries across multiple immutable datasets. Queries are sanitized to prevent injections and restrict unsafe functions.
  • Balance Tracking:
    Users have on-chain balances (balance()) and pending adjustments (unsynced_balance()), enabling microtransactions for resource usage.
  • Immutable Operations:
    All object creations (feeds/views/automations) produce auditable metadata (ObjectMetadata) with creator IDs and timestamps.

How Analog Watch Works

Analog Watch Architecture: End-to-End Workflow
  1. Users create immutable objects through an API. Users must be authenticated to deploy these artifacts. Check out Authentication to learn more.
  2. Objects are assigned unique identifiers and cryptographic hashes.
  3. Analog Watch indexes the referenced blockchain data at regular intervals based on the configured clock.
  4. Data can be queried through SQL-compatible interfaces via Watch SDK or Watch Portal .
  5. Automations can be triggered by data events, creating new data, or executing actions.

Analog Watch charges fees based on resource usage. You'll pay microtransactions determined by INDEXING_FEE constants and the resources your operations consume, tracked through your balance. See Fees & Rewards for more details.

pub const INDEXING_FEE: u128 = 50_000; // Per-row fee pub struct User { ... pub balance: u128, pub unsynced_balance: i128, }

All data operations deduct INDEXING_FEE (50,000 units) per row processed, with fee validation occurring during query planning. User accounts track two distinct balances:

  1. Confirmed Balance (balance): Settled funds
  2. Unsynced Balance (unsynced_balance): Pending transactions

This dual-balance system enables real-time accounting while supporting eventual consistency across the protocol.

Example Use Case

  1. A user defines a Feed to index NFT transfers from Ethereum.
  2. The system periodically indexes new transfers into an IPFS-hashed table.
  3. A View combines this data with pricing information from another Feed.
  4. An Automation triggers a WASM function to send alerts when high-value trades occur.