# Built-in jobs

There are two built-in worker jobs which are set to run on a cron schedule:

  • removeOldWorkerJobs - Removes successfully completed jobs. Runs every minute.
  • watchChain - Watches the blockchain for changes according to user-defined filters. Runs every 5 seconds.

# Watching the blockchain

Watching and reacting to blockchain events is done by defining user-defined filters in the src/worker/chainFilters folder. The built-in watchChain job uses these filters to watch the blockchain for changes.

The chain to watch is defined by the chain-related environment variables.

Each filter module must adhere to the following interface:

export interface ChainFilterModule {
  /** Create the filter to watch the chain. */
  createFilter: (chainClient: BootstrappedApp['chainClient']) => any
  /** Callback triggered when filter has changes to process. */
  processChanges: (app: BootstrappedApp, changes: any) => Promise<void>
}