Back to Hub
CREATED BY CHAINLINK LABS

Keeper Bot

Cron-based smart contract maintenance โ€” read state, check condition, execute if needed using the universal keeper pattern.

Get the template
cre init --template=keeper-bot-ts
View on GitHub

What This Template Does

This template implements the universal cron โ†’ read โ†’ check โ†’ write pattern for periodic smart contract maintenance.

The workflow:

  1. Cron trigger fires every 5 minutes (configurable)
  2. Reads needsUpkeep() from the on-chain KeeperConsumer contract
  3. If upkeep needed: Encodes a new counter value, generates a DON-signed report, and writes on-chain via KeystoneForwarder
  4. If not needed: Logs and skips โ€” no wasted gas

This pattern is a direct replacement for Gelato Web3Functions and Chainlink Automation.

Key Technologies:

  • CRE (Chainlink Runtime Environment) โ€” Orchestrates periodic workflows with DON consensus
  • Off-chain condition checking โ€” No gas wasted on failed checks
  • Configurable scheduling โ€” Standard cron expressions

How It Works


Getting Started

1 Install dependencies
cd my-workflow && bun install && cd ..
2 Run tests
cd my-workflow && bun test
3 Simulate the workflow

Dry run:

cre workflow simulate my-workflow --target staging-settings

With broadcast (writes on-chain):

cre workflow simulate my-workflow --target staging-settings --broadcast
4 Deploy your own contract

Deploy KeeperConsumer with constructor arguments: forwarder address and interval in seconds (e.g., 300 for 5 minutes):

forge create src/KeeperConsumer.sol:KeeperConsumer \
  --broadcast --private-key <KEY> --rpc-url <RPC> \
  --constructor-args 0x15fc6ae953e024d975e77382eeec56a9101f9f88 300

Then update contractAddress in my-workflow/config.staging.json.

Customization

  • Change schedule โ€” Edit schedule in config.staging.json (cron syntax)
  • Change condition โ€” Replace needsUpkeep() with any view function
  • Change action โ€” Modify _processReport() logic in the contract

For full details, see the TypeScript README on GitHub.

Get the latest Chainlink content straight to your inbox.