➡️Writing Solidity Functions
1. Understand the Role of a Checker
A Checker acts as a bridge between conditions and smart contract executions. Its purpose? To check conditions and determine whether a task should be executed by Gelato. Every Checker returns two main things:
canExec (Boolean): Indicates if Gelato should execute the task.
execData (Bytes): Contains the data that executors will use during execution.
Solidity functions must adhere to the block gas limit for checker calls; exceeding it will cause the call to fail.
2. Solidity Function Example
Before we delve into complexities, let's understand the structure of a simple Checker:
In the above, the checker checks the state of a counter and prompts Gelato to execute if 3 minutes (180 seconds) have elapsed since its last execution.
3. Making your Checker Reusable
Avoid hardcoding addresses. Instead, allow the passing of arguments to your checker. This lets you reuse the checker for multiple tasks:
4. Advanced: Checking Multiple Functions
Suppose you're automating tasks across different pools. Instead of creating multiple tasks, iterate through your list of pools within a single checker:
5. Incorporating Feedback with Logs
With the Gelato Web3 Functions UI, you can use custom return messages to pinpoint where your checker might be "stuck":
6. Limit the Gas Price of your execution
On networks such as Ethereum, gas will get expensive at certain times. If what you are automating is not time-sensitive and don't mind having your transaction mined at a later point, you can limit the gas price used in your execution in your checker.
This way, Gelato will not execute your transaction if the gas price is higher than 80 GWEI.
Last updated