Define function inputs
If the function you are automating accepts arguments, there are two ways you can define the arguments.

Pre-define inputs (No resolver)

Pre defining the function arguments would mean that every time Gelato calls the function, it would be using the same argument.

Dynamic inputs via Resolver

By using a resolver, you can dynamically encode the arguments of the function you are automating.
Here is an example.
This is the function we are automating. increaseCount increases a counter on the smart contract by amount which is the argument.
1
function increaseCount(uint256 amount) external onlyPokeMe {
2
require(
3
((block.timestamp - lastExecuted) > 300),
4
"Counter: increaseCount: Time not elapsed"
5
);
6
7
count += amount;
8
lastExecuted = block.timestamp;
9
}
Copied!
This resolver returns the data to the function call increaseCount.
1
function checker()
2
external
3
view
4
override
5
returns (bool canExec, bytes memory execPayload)
6
{
7
uint256 lastExecuted = ICounter(COUNTER).lastExecuted();
8
9
canExec = (block.timestamp - lastExecuted) > 300;
10
11
uint256 countToIncrease = ICounter(COUNTER).count * 2
12
13
execPayload = abi.encodeWithSelector(
14
ICounter.increaseCount.selector,
15
countToIncrease
16
);
17
}
18
Copied!
The increment on each execution is different every time as countToIncrease is different after every execution.
Last modified 30d ago