Question regarding VRFCoordinatorV2Mock (Who is calling fulfillRandomWords()?) #1641
-
Hey devs, I have a doubt regarding the VRFCoordinatorV2Mock. From the contract using VRF (i.e. VRFConsumerBaseV2) vrfCoordinator.requestRandomWords() will be called to obtain random words. I checked in the VRFCoordinatorV2Mock, requestRandomWords just emits event RandomWordsRequested(...) . contract VRFCoordinatorV2Mock is VRFCoordinatorV2Interface {
.
..
...
function requestRandomWords(
bytes32 _keyHash,
uint64 _subId,
uint16 _minimumRequestConfirmations,
uint32 _callbackGasLimit,
uint32 _numWords
) external override onlyValidConsumer(_subId, msg.sender) returns (uint256) {
if (s_subscriptions[_subId].owner == address(0)) {
revert InvalidSubscription();
}
uint256 requestId = s_nextRequestId++;
uint256 preSeed = s_nextPreSeed++;
s_requests[requestId] = Request({subId: _subId, callbackGasLimit: _callbackGasLimit, numWords: _numWords});
emit RandomWordsRequested(
_keyHash,
requestId,
preSeed,
_subId,
_minimumRequestConfirmations,
_callbackGasLimit,
_numWords,
msg.sender
);
return requestId;
}
.
..
...
function fulfillRandomWords(uint256 _requestId, address _consumer) external {
fulfillRandomWordsWithOverride(_requestId, _consumer, new uint256[](0));
}
.
..
...
} You can find the VRFCoordinatorV2Mock.sol at chinlink github here: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@alymurtazamemon , can you help me understand this? |
Beta Was this translation helpful? Give feedback.
-
Thanks @alymurtazamemon for the explaination. |
Beta Was this translation helpful? Give feedback.
@alymurtazamemon , can you help me understand this?