Introduction
An overview of the CoW Protocol Watch Tower for monitoring and executing programmatic ordersWhat is Watch Tower?
The Watch Tower is a standalone application that monitors the blockchain for programmatic orders created through the CoW Protocol programmatic order framework. It acts as a critical infrastructure component that bridges on-chain conditional orders with the CoW Protocol OrderBook API.“Watch Tower keeps an eye on Composable Cows, automatically detecting new conditional orders and posting eligible discrete orders to the orderbook.”
Why does it exist?
Programmatic orders in CoW Protocol allow users to define conditional trading logic on-chain through smart contracts. However, these orders need to be:- Discovered - The watch tower monitors blockchain events to detect when new conditional orders are created
- Evaluated - It continuously polls conditional orders to check if their execution conditions are met
- Submitted - When conditions are satisfied, it posts the resulting discrete orders to the CoW Protocol OrderBook API
How it fits into CoW Protocol
The watch tower serves as the execution layer in CoW Protocol’s programmatic orders architecture: The watch tower operates as a decentralized service - anyone can run their own instance to monitor specific addresses or provide redundancy for the network.Key capabilities
Event monitoring
The watch tower tracks two primary events emitted by theComposableCoW contract:
ConditionalOrderCreated- Emitted when a single conditional order is createdMerkleRootSet- Emitted when a batch of conditional orders (merkle tree) is set for a safe
Persistent registry
All discovered conditional orders are stored in a local LevelDB database, maintaining:- Active conditional orders by owner (safe address)
- Order parameters and merkle proofs
- Last processed block information
- Submitted discrete order status
The watch tower uses LevelDB for its ACID guarantees. If a write fails, the application exits and automatically re-processes from the last successful block on restart, ensuring eventual consistency.
Continuous polling
For each registered conditional order, the watch tower:- Calls the order’s poll method with current block context
- Evaluates if trading conditions are satisfied
- Submits discrete orders to the OrderBook API when conditions are met
Multi-chain support
The watch tower can monitor multiple chains simultaneously, including:- Ethereum Mainnet
- Arbitrum One
- Gnosis Chain
- Base
- Sepolia (testnet)
Use cases
For protocol integrators
Run your own watch tower instance to:- Monitor specific safe addresses or contracts
- Ensure reliable execution of your users’ programmatic orders
- Maintain independence from third-party infrastructure
For DApp node operators
The watch tower is available as a DAppNode package, allowing you to:- Contribute to CoW Protocol’s decentralized infrastructure
- Provide redundancy for programmatic order execution
- Support the ecosystem while earning potential rewards
For development and testing
Use the watch tower locally to:- Test programmatic order implementations
- Debug conditional order logic
- Validate order execution flow
Getting started
The watch tower can be deployed in several ways:Docker (recommended)
Local development
DAppNode
Install the CoW Watch Tower package directly from the DAppNode package manager.Requirements
To run your own watch tower instance, you’ll need:- RPC node - Connected to your target chain(s) with sufficient rate limits
- Internet access - To communicate with the CoW Protocol OrderBook API
- Storage - For the LevelDB database (default:
./database) - Configuration - A valid
config.jsonspecifying your deployment settings
The
deployment-block configuration refers to the block number where the ComposableCoW contract was deployed. This optimizes the watch tower by only fetching events after this block.Next steps
- Learn about the Architecture and how the watch tower processes events
- Review configuration options in the example
config.json.example - Explore the source code on GitHub