Search code examples
multiversx

How to create a smart contract which will execute everyday at the same hour?


The title is pretty explanatory. I want a batch which will execute everyday, at the same hour. Like a batch.

Also, is it possible to have a smart contract with endpoints and batch executing inside?


Solution

  • Currently there is no way to schedule a smart contract execution inside a smart contract.

    Meaning if you want to call a function in the smart contract you have to send a transaction to the smart contract. To achieve this at the same time everyday you would have to use something like a cronjob on a traditional backend.

    Not sure what you mean with endpoints and batch executing, but you can also make read only functions using the #[view] makro, instead of the #[endpoint] makro you would normally use for public functions. These view functions can be called without requiring a transaction using the query endpoint.

    And of course you can use loops inside your smart contract to execute a bunch of things at the same time.