ChainLink Automation — Practical Guide#
ChainLink Automation (formerly Keepers) lets you trigger on-chain function calls on a schedule or in response to custom conditions — without running your own bot infrastructure.
When to Use It#
- Periodic maintenance — harvesting yield, rebasing tokens, updating oracles.
- Conditional execution — liquidations, limit-order fills, rebalancing when a threshold is crossed.
- Replacing cron bots — any off-chain script that just calls a contract method can usually move to Automation.
Core Concepts#
| Term | Meaning |
|---|---|
| Upkeep | A registered job — the thing Automation monitors and executes. |
| Trigger | What fires the upkeep: time-based (cron) or custom logic (conditional). |
checkUpkeep |
View function Automation calls off-chain to ask “should I execute?” |
performUpkeep |
State-changing function Automation calls on-chain when checkUpkeep returns true. |
| LINK funding | Each upkeep has a LINK balance that pays node operators per execution. |
Supported Networks#
Automation is live on Ethereum mainnet, Arbitrum, Optimism, Polygon, Avalanche, BSC, and Base (among others). Check the ChainLink docs for the current list and registry addresses.
Step-by-Step: Register a Custom-Logic Upkeep#
1. Implement the Automation Interface#
Your contract must expose checkUpkeep and performUpkeep:
|
|
Important: Always re-check the condition inside
performUpkeep. Between the off-chain check and on-chain execution, state can change.
2. Deploy & Verify#
Deploy to your target network and verify on the block explorer so the Automation UI can read the ABI.
|
|
3. Register the Upkeep#
Option A — UI
- Go to automation.chain.link.
- Connect your wallet and select the correct network.
- Click Register new Upkeep.
- Choose Custom logic as the trigger.
- Paste your contract address — the UI will detect
checkUpkeep/performUpkeep. - Set a name, gas limit, and starting LINK balance (5 LINK is a safe minimum for testing).
- Confirm the transaction.
Option B — Programmatic (Solidity)
|
|
4. Fund & Monitor#
- Top up LINK before the balance runs out — Automation pauses unfunded upkeeps.
- Use the dashboard at automation.chain.link to view history, gas usage, and remaining balance.
- Set up a low-balance alert (the UI supports email notifications).
Step-by-Step: Time-Based (Cron) Upkeep#
If you just need a function called on a schedule, you can skip checkUpkeep entirely:
- Register via the UI and choose Time-based trigger.
- Enter a cron expression (e.g.
0 */6 * * *for every 6 hours). - Select the target contract and function — the UI lets you pick from the ABI.
- Fund with LINK and confirm.
No interface changes to your contract are required for time-based upkeeps.
Log-Trigger Upkeeps#
Automation can also fire in response to a specific event log:
|
|
Register with trigger type Log trigger, specify the event signature and optional topic filters. Automation watches for matching logs and calls performUpkeep with the log data encoded in performData.
Gas & Cost Considerations#
- Gas limit — set it high enough for worst-case execution. Unused gas is not charged.
- Premium — Automation charges a percentage premium on top of gas (varies by network, typically 20–80 %).
checkUpkeepcost — runs off-chain, so it doesn’t cost gas, but keep it lightweight to avoid simulation timeouts (target < 5 M gas).- Batch awareness — if many upkeeps fire in the same block, the network can get congested. Design
performUpkeepto be gas-efficient.
Testing Locally#
Use a Foundry fork test to simulate the Automation cycle:
|
|
Security Checklist#
-
performUpkeepre-validates the trigger condition on-chain. -
performUpkeepis access-controlled or idempotent — anyone can call it, not just Automation nodes. - No unbounded loops in
checkUpkeep(simulation gas limit applies). - LINK funding is monitored to prevent upkeep pausing at a critical moment.
- Contract is verified on the block explorer for transparency.