How to Automate Your Smart Contract Executions Using Gelato
Gelato Team
•
Apr 24, 2023

If you've ever built a smart contract, you know that it can’t execute functions automatically on its own based on conditions — for example, selling ETH when the price spikes. To achieve this, you’d usually need to build and maintain your own bot to monitor conditions and trigger transactions, which requires time, servers, and ongoing supervision.
Fortunately, with Gelato, this isn’t your problem anymore!
Let’s Begin
Suppose you already have a deployed smart contract and want Gelato to call a function at a set interval. All you need to do is deploy a resolver contract that tells Gelato:
“Call this function every hour.”
Here’s an example of a function buy()
that buys ETH through Uniswap V2. We want Gelato to call it once per hour:
Below is an example of a resolver contract. The checker()
function returns true if it has been at least one hour since lastBought
, prompting Gelato to call buy()
.
Gelato calls checker()
off-chain at every block. If canExec
is true, Gelato executors will send a transaction with execPayload
.
Read more about resolvers in the official guide here.
Task Creation
Once your resolver contract is deployed, the next step is to create a task. Gelato makes this simple via the Gelato Automate UI:
Visit the Gelato Automate app.
Fill in your execution address (the contract with the function you want to call).
Select the function and choose “Dynamic inputs via Resolver.”
Enter your resolver contract address and select the
checker()
function.Deposit funds into your Gelato balance to pay executors.
Name your task and create it.
Once done, you’ll be redirected to your task page, where you can monitor all executions in real time.
All Done!
Gelato will now monitor your smart contract and automatically execute when your conditions are met.
Check out the full list of supported network contract addresses to get started quickly.
About Gelato
Gelato is a Web3 Cloud Platform empowering developers to build automated, gasless, and off-chain-aware smart contracts and Layer 2 chains. More than 400 projects trust Gelato to facilitate millions of transactions in DeFi, NFTs, and gaming.
Gelato RaaS: Deploy tailor-made ZK or OP L2 chains with Gelato middleware baked in.
Web3 Functions: Connect smart contracts to off-chain data with decentralized cloud functions.
Automate: Execute contracts automatically via reliable, decentralized infrastructure.
Relay: Enable gasless transactions for your users through a simple API.
Account Abstraction SDK: Built with Safe, combining Gelato’s gasless infra with the most secure smart contract wallet.
👉 Subscribe to our newsletter and turn on Twitter notifications for the latest Gelato updates.
👉 Interested in helping build the future of the internet? Explore open positions and apply here.