Inspiration
Wanted to do a game related NFT. Something that makes the NFT more than just an image, video, or song. I understood early on that since blockchain development is something I am fairly new to, I would have to aggressively control scope.
What it does
MFG NFT Dice allows you to buy packs of 6-sided dice represented as NFTs (ERC1155 standard) with randomly selected colors using Chainlink’s VRF features for on-chain randomness.
The Minting/Collection page shows the dice that you own and allows you to mint more by pressing the “Mint Pack” button. There is a 0.25 MATIC fee to mint a new pack. Each pack minted also grants you an MFG NFT Dice DAO Token for future Voting/DAO functionality.
The Play page randomly selects 5 dice from your collection (press “Pick Dice” to do a new random draw). The “Roll Dice” button engages a separate smart contract that will use Chainlink’s VRF features for on-chain randomness. There is a 0.005 MATIC fee to roll the dice.
The Admin page allows the admin to deposit/withdraw LINK from both smart contracts (DiceNFT.sol and RollBones.sol). It will also allow the admin to withdraw MATIC from both contracts. Note: anyone can deposit to a contract but only the admin can withdraw.
How we built it
Used Remix for contract deployment and initial testing.
Used Moralis for web3 integration, metamask login, smart contract interaction, and static site hosting.
Leveraged the p5.js library to create the graphics for the dice and also to handle the UI and animation for rolling the dice on the play screen. I am pretty familiar with p5.js so that part was less of a challenge.
Challenges we ran into
Time (I'm sure everyone says that).
Understanding ERC1155 vs ERC7221.
Reacting to smart contract events on the client side.
Test network issues.
Accomplishments that we're proud of
Very proud that I was able to control scope and actually ship something.
Fighting through listening for smart contract events on the client side. That one took some time, even with many Google searches.
What we learned
Became much more comfortable with solidity and web3.
ERC1155
Definitely start with Brownie or Hardhat next time for a faster dev/test cycle.
How to build a real-world dApp... something that goes beyond a simple tutorial.
What's next for MFG NFT Dice
Use IPFS hosting for the NFTs.
DAO / Voting Functionality.
Add more dice (d4, d8, d10, d12, d20, d100) a la D&D dice.
Leverage three.js to create a rendered 3d view of the dice.
Use shaders and three.js to make those 3d dice shiny, sparkly, and with multiple color swirls.
Convert to a web framework like React or Vue.
Shift from Remix to Brownie for a better development / testing workflow.
Because of time constraints RollBones.sol is just a reference implementation of a game. Create actual games that leverage the DiceNFT.sol smart contract.
Add functionality that leverages the MATIC collected in both contract to swap and self fund the LINK needed to fuel Chainlink VRF.
Built With
- alchemyapi
- bootstrap
- chainlinkvrf
- erc1155
- html
- javascript
- moralis
- mumbai
- p5.js
- polygon
- solidity
Log in or sign up for Devpost to join the conversation.