Testnet only (Arkiv Tiramisu). OpenTrigger 0.1 has not had an outside audit.
OpenTrigger

Run your own code

Embed a worker in your backend and run your own code when one of your rules fires.

Public workers only run the four actions. On a worker you run yourself, you can also run your own code when one of your rules fires: send an email, post to Slack, update a database.

import { startWorker } from 'arkiv-triggers/worker'

const worker = await startWorker({
  privateKey: process.env.WORKER_KEY as `0x${string}`,
  accessKey: process.env.ARKIV_ACCESS_KEY,
  mode: 'own',
  onFire: async (rule, { deadline, firedAt, eventId }) => {
    await sendEmail(`${rule.name} fired at block ${firedAt}`)
  },
})

Then create rules assigned to it: worker: worker.address.

  • onFire is called only for rules whose worker is this worker's address, never for public rules, so a stranger's rule can never run your code.
  • It runs after the rule's own action. If it throws, the receipt records failed with error: "onFire: …".
  • Keep it inside the worker's time budget (a few seconds). eventId is stable across retries, for de-duplication.

stop() finishes actions in flight and stops the loop:

process.on('SIGTERM', async () => { await worker.stop(); process.exit(0) })

See Worker reference for every option.