I'm making a simple lottery game where there are hourly, daily and weekly prizes. My contract has functions to pick winners for each of these game types. Each game types will have different number of entries and I need to generate a random number based on the number of entries to pick the winner.


function chooseHourly() public {
   address HourlyWinner = pickWinner(hourlyParticipants);

function chooseDaily() public {
   address dailyWinner = pickWinner(dailyParticipants);

function chooseWeekly() public {
   address weeklyWinner = pickWinner(weeklyParticipants);

 function __callback(
        bytes32 _queryId,
        string memory _result,
        bytes memory _proof
        require(msg.sender == provable_cbAddress());

        if (
            ) != 0
        ) {
            revert("Proof verification failed.");
        } else {            
            randomNumber = uint256(keccak256(abi.encodePacked(_result)));
            emit generatedRandomNumber(randomNumber);

function pickWinner(Entry[] memory entries) internal returns(address) {

        uint256 GAS_FOR_CALLBACK = 200000;
    //Need to return a winner somehow. If I pick winner here, it would probably use the previously generated number, not the one just requested.

However I would need to wait for the callback function to select the winning address in pickWinner and the callback function has no knowledge of which game it will be. I'm not sure of the best way to structure this. I don't really want to create separate contracts for each game type, but is it possible to have more than one different oracle call per contract or is there another way to go about this?

  • the callback function has no knowledge of which game it will be - what exactly prevents you from passing that little piece of information to the callback function? Jan 23, 2020 at 10:39
  • Provable calls the callback function after the Provable_newRandomDSQuery is called, right? How would you pass the game type and return the correct winning address from the participants array?
    – koukotsu
    Jan 23, 2020 at 10:53

1 Answer 1


You cannot pass on additional information while querying provable, and due to this we cannot have any additional information with us when callback is received as callback is sent us by provable

You can give each match a specific id and then make a call to provable with that specific id As when we query provable and receive callback it provides us query id parameter

  • Could you give us more detail about how to give an id? An example would be awesome! Apr 8, 2020 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.