Search⌘ K
AI Features

Solution: Part 1

Explore how to structure a Play-to-Earn Treasure Hunt game by separating VRF-based randomness logic from non-random components using Solidity inheritance. Understand token gating, modifiers, and building secure game and payment functions within Ethereum smart contracts.

Inheritance structure

For clarity and code maintainability, we'll separate VRF-related code from the parts of our game that don't depend on randomness.

  • TreasureHuntNoVRF.sol is a base contract containing state variables and modifiers that don't depend on the VRF.

  • TreasureHuntVRF.sol will inherit from TreasureHuntNoVRF.sol and contain all VRF-related inheritance, state variables, and an override implementation of the VRF fullfillRandomWords() function. However, it will not implement the constructor inherited from the VRF contracts; we'll save its ...