What This Template Does
This template implements the universal cron โ read โ check โ write pattern for periodic smart contract maintenance.
The workflow:
- Cron trigger fires every 5 minutes (configurable)
- Reads
needsUpkeep()from the on-chainKeeperConsumercontract - If upkeep needed: Encodes a new counter value, generates a DON-signed report, and writes on-chain via
KeystoneForwarder - 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
scheduleinconfig.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.
CREATED BY CHAINLINK LABS