Smart contract implementation for quest-based games. Players get NFT accounts that they can use to complete quests and earn XP.
QuestNFT is a smart contract implementation deployed to Optimism that allows anyone to create and run a quest-based game. In QuestNFT, players mint NFTs which are used as their on-chain save files. These NFTs can earn XP as players complete various quests. The power of QuestNFT is a flexible and composable quest structure that allows the game masters to create a variety of challenges for players. QuestNFT provides built-in task types that a game master can mix and match in a given quest. Game masters can keep adding more quests indefinitely, allowing for an ongoing game that evolves over time. See more in our slide deck here: https://docs.google.com/presentation/d/1TD6x_8abbYt_YIXyY_ACG-FliU5D4BJxvRsYOhdo06c/edit?usp=sharing and our GitHub repo here: https://github.com/BradleyC/QuestNFT
This project is a Solidity repo designed and developed with the benefits of Optimism/L2 in mind. The repo is built with Solidity + Hardhat. One challenge of this project was building a data model for Quests that allowed for infinite flexibility. To do this, we created a "Task" model, where each Quest is composed of an unlimited number of Task functions. All Task functions within a quest must return "true" for that Quest to be completed by a given player. Iterating through all tasks and evaluating them would be prohibitively expensive on Ethereum L1, but Optimism and other L2s provide an environment where verifying complex on-chain goals is more feasible. After we built our "Tasks" function model + evaluation engine, we also wanted game makers to be able to develop their own custom tasks outside of our framework. To solve for this, we also added a solidity interface "IAbstractTask.sol." This actually allows developers to code and deploy their own Quests that can be added to their game. Finally, we were inspired by on-chain SVG and the ability for NFTs to be rendered dynamically on-chain. To do this, we built a tokenURI function for QuestNFTs that displays a live value of a player's earned XP. See more in our README here: https://github.com/BradleyC/QuestNFT