BasicRandcastConsumerBase

BasicRandcastConsumerBase contract provides:

  • A set of virtual callback functions that the consumer contract can override. These functions are called by the Adapter contract when the randomness request is fulfilled. The consumer contract can override the below functions to implement the subsequent logic on how to utilize the randomness results in their DApp or Web3 game, specifically:

    • override _fulfillRandomness for requesting Randomness

    • override _fulfillRandomWords for requesting RandomWords

    • override _fulfillShuffledArray for requesting Shuffling

  • A nonce recorder keeps track of the number of random requests that the consumer contract has initiated through a specific subscription. This can be useful for debugging. Please do not try to control the nonce as it will not affect the behavior of the Adapter, i.e., randomness result.

  • A _rawRequestRandomness function to call the Adapter contract to request randomness. The consumer contract can define its own interface to request randomness, where this function should be called. The user can set:

    • subId to specify which subscription to use.

    • seed to specify the seed of the randomness (this won't decide the randomness result but will help prevent other parties from maliciously predicting it).

    • requestConfirmations to specify the number of blocks required between the randomness request and the randomness fulfillment.

    • callbackGasLimit to specify the gas limit you want for the callback function.

    • callbackMaxGasPrice to specify the maximum amount of gas you are willing to spend on the callback request.

Note: To learn more about the implementation, please refer to the complete source code of the smart contract.

Last updated