Run autotasks in seconds

I want to check for condition before executing the txn in autotask, so in that case Is it possible to reduce the timespan of frequency to seconds? Txn will not be submitted every second, but autotask should check for every x seconds and run the txn. Is there any way to achieve this?

:computer: Environment

:memo:Details

:1234: Code to reproduce

Hi @kbhargav5

We have set the minimum frequency in minutes to decrease the probability of previous autotask runs overlapping with current ones, and causing unexpected results. I don't believe there is a way to achieve this as of now, however, I will further discuss with the team and keep you posted if this is something we want to consider in the future.

Hi @kbhargav5

It looks like there is a hard limit that we cannot run more often than 1 min. That's how often the scheduler runs, and that's the minimum granularity for the AWS scheduler itself.

Some of our users seem to have "resolved" this with a continuously running autotask, which isn't ideal, but this may help for your use-case as well. Have a look at:

@nami,

But this is for keepers jobs, how do we do for the regular autotask runs. Even if we embed this code in autotask, we can schedule this only for minimum 1 minute

Hi @kbhargav5, reading your original post, I think what you might need here is a Sentinel. Sentinels continuously listen for transactions and events on the blockchain, and let you trigger an Autotask as soon as the monitored condition is detected. This would let you trigger an Autotask upon the specific condition you're monitoring without having to continuously poll the blockchain through an Autotask.

So, could you tell us a bit more about your use case to see if this could help in your particular case?

@MartinVerzilli
sentinels will monitor the txns mined in the blockchain. But I want to check for condition before submitting txn with autotask. Consider I need to submit txn every 5 minutes whenever a condition is met on contract, in this case I need to check for condition every 5 secs or so and then submit the txn

If the condition you want to monitor isn't currently monitor-able with a Sentinel we'd love to hear more details about it! We might be able to enhance the Sentinel component to make it powerful enough to handle it :).

In the meantime, again if the condition is not something you can monitor with a Sentinel, you can use the Autotask Runs API to trigger it whenever you want https://docs.openzeppelin.com/defender/autotasks-api-reference#runs-endpoints.

Another similar option is to configure your Autotask to be runnable through a webhook https://docs.openzeppelin.com/defender/autotasks#webhook-handler.

Naturally, the maximum amount of runs per hour is still the same, regardless of how the Autotask was run.

Hope this helps!