Skip to content

difference between VRFCoordinatorV2Interface and VRFConsumerBaseV2 #2232

Discussion options

You must be logged in to vote

First about VFRConsumerBaseV2:
In order to use VRFCoordinator our contract as the consuming contract must inherit (i.e. contract Lottery is VRFConsumerBaseV2 {}) VRFConsumerBaseV2 and implement the fulfillRandomWords function inside our consumer contract itself,

function fulfillRandomWords(
		uint256, /*requestId*/
		uint256[] memory randomWords
	) internal override {
		uint256 indexOfWinner = randomWords[0] % s_players.length;
		address payable recentWinner = s_players[indexOfWinner];
		s_recentWinner = recentWinner;
		(bool success, ) = recentWinner.call{value: address(this).balance}("");

		if (!success) {
			revert Lottery__TransferFailed();
		}

		emit WinnerPicked(recentWinner);
		s…

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@TimeKeyRoll
Comment options

@othaime-en
Comment options

@TimeKeyRoll
Comment options

@adityabhattad2021
Comment options

@TimeKeyRoll
Comment options

Answer selected by TimeKeyRoll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants