Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
745 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.7k users

...