Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
897 views
in Technique[技术] by (71.8m points)

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

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?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Yes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...