Regular, repeating, interaction between an oracle and a smart contract

青春壹個敷衍的年華 提交于 2021-02-11 12:27:09

问题


This is just an example. I'm building this dapp where I have a start date and an end date and every day I want to get a random number from an oracle. If at some point the sum of the numbers I get every day exceeds a threshold then an OK message returns to my backend. Let's assume we have a range of 7 days.

Day 1:

  • My backend sends a request to the "smart contract Number" and calls the requestOk () method.
  • The smart contract Number calls the gethNumber () method of the oracle smart contract and passes it the callback on which to return the response.
  • The oracle smart contract issues an updateN () event
  • The oracle service retrieves the data and returns it to the oracle smart contract by calling the UpdateNumber () method
  • The oracle smart contract uses the callback and returns the data to the smart contract Number
  • The smart contract Number checks if the number received that day is greater than a threshold. If it is greater, an ok message returns to the backande, otherwise the same procedure is performed for day 2, I take the new number and add it to the number of day 1. Finally I compare the sum (day number 1 + day number 2) with the threshold and so on.

Now my question is: can the operations I have to perform again for day 2 automatically start from the smart contract Number? I mean, is it possible to create a mechanism allows the smart contract Number to ask the oracle for a random number every day for a week? Or must it be my backend asking to do the same operations for day 2 and every day of the week?


回答1:


Or must it be my backend asking to do the same operations for day 2 and every day of the week?

Yes.



来源:https://stackoverflow.com/questions/65944313/regular-repeating-interaction-between-an-oracle-and-a-smart-contract

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!