Gelato Network
Search…
⌃K

Single Execution Task

Sometimes, you might want to have Gelato call your function only once. If so, you can make use of the SingleExec module which automatically cancels the task for you after one execution.
The task will still be canceled if the execution reverts on-chain
Here is how you can enable SingleExec when creating your task across the various task creation methods.

Gelato Automate UI

Open up the Advanced Settings panel when creating a new task and select Single execution task:
Accessing the single execution task option in Advanced Settings

Gelato Automate SDK

Set singleExec flag to true when calling createTask.
const { taskId, tx }: TaskTransaction = await gelatoOps.createTask({
execAddress: counter.address,
execSelector: selector,
resolverAddress: counter.address,
resolverData: resolverData,
dedicatedMsgSender: true,
name: "Automated counter using resolver",
dedicatedMsgSender: true,
singleExec: true
});

Smart Contract

Include SingleExec module in ModuleData.modules . Check out the full code here.
ModuleData memory moduleData = ModuleData({
modules: new Module[](2),
args: new bytes[](2)
});
moduleData.modules[0] = Module.PROXY;
moduleData.modules[1] = Module.SINGLE_EXEC;
moduleData.args[0] = _proxyModuleArg();
moduleData.args[1] = _singleExecModuleArg();
bytes32 id = _createTask(
address(this),
execData,
moduleData,
address(0)
);