简体   繁体   中英

Can my backend call a smart contract function to be executed on a certain date?

The architecture of my dapp consists of a backend (metamask + web3.js or web3.js + geth) and a smart contract that offers different services (functions). I want a function on the smart contract to run on a certain date. Can my backend call a smart contract function to be executed on a certain date? If it can, how?

You can set up a one-time command using 'at' command in unix to run a script file. The script file can be broadcasting a transaction calling the function on your smart contract.

If you plan to call the function every day or repeatedly, you can use 'cron' at unix.

https://www.linuxjournal.com/content/schedule-one-time-commands-unix-tool https://www.ibm.com/developerworks/library/l-job-scheduling/index.html

Added to @ming question I would also say that it's important that your Smart Contract verify that it is the good moment to be called otherwise you inmutable logic will be a little weak and dependant only on the callers call.

Can my backend call a smart contract function to be executed on a certain date? If it can, how?

Usually these kind of calls cannot be guaranteed. It is better to create a function that anyone can call after a certain date. Even if your backend fails, others can pick up the work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM