Solution: Part 2

Build our own play-to-earn game.

VRF-related abstract contract

In the following code, we'll define an abstract TreasureHuntVRF.sol contract that contains the setting parameters of the VRF and the aspects of our game that depend on randomness. We don't implement any function in this abstract contract, except for the VRF callback function fulfillRandomWords(), which requires some adjustments for our game. We must mark the contract as abstract because it doesn't implement the VRF constructor. We'll save that for the last contract, which will inherit from this abstract contract and implement all functions.

Get hands-on with 1200+ tech skills courses.