config.json file, you can run the Watch Tower locally.
Basic usage
Run the Watch Tower with the default configuration:CLI commands
The Watch Tower CLI provides two main commands:run
Start the Watch Tower in monitoring mode:Path to the chain configuration file.Environment variable:
CONFIG_PATHPath to the LevelDB database directory.Environment variable:
DATABASE_PATHSet the logging level. Options: Environment variable:
TRACE, DEBUG, INFO, WARN, ERROR.LOG_LEVELRun without publishing orders to the OrderBook API. Useful for testing.Environment variable:
DRY_RUNRun the Watch Tower once and exit instead of continuous monitoring.Environment variable:
ONE_SHOTPort for the REST API server.Environment variable:
API_PORTDisable the REST API server.Environment variable:
DISABLE_APIDisable notifications (local logging only, no Slack alerts).Environment variable:
DISABLE_NOTIFICATIONSSlack webhook URL for error notifications.Environment variable:
SLACK_WEBHOOKMonitor conditional orders only from specific owner addresses (safes). Can be specified multiple times.
dump-db
Dump the database contents as JSON:Expected output
When you start the Watch Tower, you should see output similar to:What the Watch Tower does
When running, the Watch Tower continuously:- Monitors blockchain events - Listens for
ConditionalOrderCreatedandMerkleRootSetevents - Fetches conditional orders - Retrieves order details from the blockchain
- Posts discrete orders - Submits orders to the CoW Protocol OrderBook API
- Updates registry - Maintains a local database of active conditional orders
- Removes expired orders - Cleans up orders that have expired or been cancelled
Accessing the API server
By default, the Watch Tower starts a REST API server on port 8080 with the following endpoints:Version information
Configuration
Database dump
Prometheus metrics
Viewing logs
The Watch Tower uses a flexible logging system that can be controlled via theLOG_LEVEL environment variable.
Basic log levels
Set the global log level:TRACE, DEBUG, INFO, WARN, ERROR
Module-specific logging
Enable detailed logging for specific modules:Advanced logging patterns
Use regex patterns to match specific logger names:Running in development mode
Set up test configuration
Create a development configuration file for Sepolia testnet:Edit to include only the Sepolia network with your test RPC endpoint.
Using environment variables
You can configure the Watch Tower entirely through environment variables:.env file:
.env
Monitoring specific safes
To monitor conditional orders from specific Safe addresses only:Stopping the Watch Tower
To gracefully stop the Watch Tower, pressCtrl+C. The Watch Tower will:
- Stop processing new blocks
- Complete any in-progress operations
- Close the API server
- Close the database connection
- Exit cleanly
Troubleshooting
Database issues
If you encounter database errors, try removing the database and resyncing:RPC connection issues
Enable debug logging to see RPC connection details:High RPC usage
Reduce RPC calls by:- Increasing
processEveryNumBlocksto skip blocks - Setting
pageSizeappropriately for your RPC provider - Using a dedicated RPC endpoint with higher rate limits