The problem DeFi-Battles ⚔️ solves
DeFi-Battles introduces a gaming aspect of the NFTs. Instead of having them as a collectible sitting in your wallet, now they can be used to battle other players' NFTs and earn rewards ✨
Much of the world is yet to be introduced to cryptocurrencies, DeFi and NFTs. Our aim with this project is to onboard them to the world of crypto with unique characters, introduce them to DeFi, deposit yields & staking in battles.
All the NFT characters on DeFi-Battles are rare and unique. All the monster characters are generated from a DNA that's uniquely generated by the Chainlink VRF. The DNA also gives them a type such as fire, water, grass etc. These characters are minted as an ERC721 token and the tokenURI is stored on IPFS. These NFTs can then be made to battle other players' NFTs by staking ETH in a winner-takes-all battle bet!
We also introduced various interesting aspects in this platform such as :
- Player VS Player battles - In which players battle other players' NFTs and earns rewards (Operational)
- Player VS Boss Battles - in this mode the boss is an NFT sponsored by advertisers and other players Battle and earn rewards based on contribution (WIP)
- The money deposited to purchase NFTs goes into an Aave pool and generates interest, hence appreciating the NFT value (WIP)
DeFi-Battles aims to be the "Top Shots" of NFTs for the Pokemon card nerds of the world. We aim to introduce them to DeFi with multipurpose NFTs and make them crypto natives. With the platform shaped as a game, we intend to gamify DeFi and make it intuitive to Gen Z and millenials.
Challenges we ran into
We faced various challenges while working on this project.
- Initially deciding what type of NFT should we have, first was unique crypto NFT which were unique based on the date of minting and value of that crypto asset. Later we moved to monster NFTs as they were much cooler, and these monsters are of different types like fire, water, grass. etc and have attacks based on that.
- The next challenge was how would we dynamically generate this NFT we solved it with Remotion it's a library to generate videos with the code written in React, the NFTs are in CSS and react and are generated on the server itself.
- Deciding the traits and character meta data generation part, the traits and meta data are based on the DNA which is generated from Chainlink VRF and all those data is stored in ifps using nft.storage.
- Deploying the NFT generation server, was slightly complex because we had to set up HTTPS, and also while working we encountered that Remotion doesn't work with 1gb VPS and it was solved by upgrading it to a 4gb one. We learned about Nginx, pm2 and HTTPS setup during this part.
- Building the flow for Token URI to be set for a newly created token was particularly hard. The token first had to be created on the ERC721 contract, an event listener picked up the DNA of the token, called an async request to the NFT generation server to generate the video for the NFT, which when generated, pushed it to IPFS and sent the hash back, which then had to make a call to the contract again to set it. All of the elements here were async and the whole flow fails if one step fails. Making this flow foolproof was hard. It still needs improvement.
- The real-time battle arena and battle contract needed real time communication b/w both participants and Web3 event listeners were too slow to notify users when their opponent has made their move. We used socket.io to solve this. With the battle contract, we used commit-reveal system to ensure security of a users' battle strategy.