Smart contract automation and keepers
What is smart contract automation?
Smart contract automation is making the contract calls a protocol needs on a schedule or in response to an onchain event, such as harvesting yield, rebalancing or settling; the bots that make these calls are called keepers.
DeFi protocols and prediction markets run keepers because a contract can’t call itself, and a missed call leaves a harvest, rebalance or settlement late.
Goldsky Compose runs each keeper as a TypeScript task started by a cron schedule or a watched contract event, and sends the call from a wallet the task controls; what to call, and when, stays with you.
Who uses smart contract automation?
DeFi protocols, yield vaults and prediction markets whose contracts need recurring or event-driven calls to keep working.
How a keeper wakes up and calls the contract
The diagram follows one keeper run, from the schedule or event that starts it to the call landing onchain, and shows who does each step. Your setup may differ.
Decide what needs calling and when
A contract only acts when something calls it, so every recurring job needs a caller and a rule.
List each function, what makes it due (a time, such as a daily harvest, or an event, such as a new deposit) and the condition that makes the call worth sending. Vague rules produce calls that waste gas or miss their window.
Grant the keeper’s address its role
Many keeper functions are restricted, so the contract has to recognize the keeper’s address.
Grant only the role the keeper needs. A keeper with admin rights turns a bug in its code into a bug that can change anything in the contract.
Run on a schedule
Handled by Goldsky ComposeHarvests, rebalances and settlements often fall due at fixed times.
The schedule has to fire on time, every time. If a run is still going when the next one starts, both can send the same call, so each run should check whether the work is already done.
A Compose cron trigger starts the task from a standard cron expression, and a six-field expression adds seconds when you need them. Moving from Gelato Web3 Functions? Its cron and interval triggers both become cron expressions in Compose.
Set up a cron trigger (opens in a new tab)Run when a contract emits an event
Handled by Goldsky ComposeSome calls fall due when something happens on a contract, such as a deposit that needs routing.
Acting on an event from a block that’s later replaced means calling for something that never happened. Holding each event until its block is a few blocks deep avoids that, at the cost of a short delay.
With Goldsky, an
Trigger a task from contract events (opens in a new tab)onchain_eventtrigger runs the task for each matching log from the contract you name. Settingconfirmationsholds each event until its block is deep enough; it needsparallel_processing: true, which runs events side by side and gives up block order.Simulate the call, then send it
Handled by Goldsky ComposeA call that would fail still costs gas, so keepers check before sending.
Simulating the call against current state shows whether it would revert. Sending without that check spends gas on calls that were never going to work, and retrying blindly repeats the loss.
Compose wallets have
Learn about Compose wallets (opens in a new tab)simulateandwriteContract. The write waits for the confirmations you set, andonReorgwithreplayresends it if a reorg removes it later.Land the call onchain
The protocol’s state moves forward once the call is included and final.
Once included, the harvest, rebalance or settlement is visible to everyone. A call that was dropped, or undone when the chain replaced its newest blocks, leaves the protocol behind until a later run catches up.
Trace every run
Handled by Goldsky ComposeWhen a call is late or fails, you need to see what the keeper saw and did.
Each run’s trigger, reads, simulations and transactions should be kept together. Without them, a missed harvest is a guess about which part failed.
Goldsky logs every context call a task makes, and each call retries on the settings you give it before the task itself retries.
How retries and logging work (opens in a new tab)
What you control
- Your team
- Decide what needs calling and when
- Grant the keeper’s address its role
Security and deployment
- SOC 2 Type IIIndependently audited security controls.
- Dedicated infrastructureSingle-tenant options for production workloads.
- Data residencyCloud, on-premises or co-located.
More use cases that run protocol automation
- Run your own oracle price feedPush prices and other data to contracts on many chains.
- Onchain circuit breakersPause a token, market or payout when a rule is breached.
- Cross-chain automationAct on one chain when an event happens on another.
- Onchain interest rate, funding rate and volatility feedsPublish interest rates, funding rates and volatility benchmarks to contracts.
- VRF and verifiable randomness for smart contractsDeliver signed random values to contracts for prize draws, lottery allocations and random selection, checkable by anyone.
Use cases built the same way
- Authorize and capture stablecoin paymentsHold a buyer’s stablecoins in an escrow contract at checkout, capture them to the merchant as orders ship, void what can’t be filled and refund after capture.
- Programmable escrow for B2B stablecoin paymentsHold a buyer’s stablecoin payment until delivery, a milestone or a deadline, then release it to the seller or refund the buyer.
- Stablecoin payroll and contractor payoutsPay contractors and staff in stablecoins and confirm each payout settled.
- Stablecoin payouts for marketplaces and creatorsPay sellers, gig workers and creators in stablecoins from a marketplace balance.
Automate smart contract calls with keepers on Goldsky
We’ll map it to your systems and show you what Goldsky runs, so your team builds the product, not the pipelines underneath it.