Mystery Box Example
This project showcases a common scenario in GameFi projects where users purchase NFT (Non-Fungible Token) boxes with the chance to claim a random NFT. In this DApp demo, users can claim the NFT box for free.
The NFT contract utilizes the Orakl VRF (Verifiable Random Function) service to generate a random number between 1 and 10, corresponding to the ID of the rewarded NFT.
Code repository
The code for this project is available in mystery box orakl. Refer to the readme.md file for detailed instructions on forking the game.
NFT Box Contract
This contract complies with the ERC-721 standard for NFTs and includes additional features.
Opening a Box
The openBox function requests a random number from the Orakl VRF service, burns the NFT, and rewards the user with the corresponding NFT.
Handling Random Number
The fulfillRandomWords function receives the random number from the Orakl VRF service and mints the corresponding NFT.
NFT Contract
This contract follows the ERC-1155 standard for NFTs and includes access control for the mint function.
Single Mint
Batch Mint
Note
Grant the minter role to the box contract to enable it to mint the rewarded NFT.
This project demonstrates how Orakl VRF can introduce randomness into NFT rewards within GameFi ecosystems, enhancing user gaming experiences.
Last updated