Hi folks, I bring you my reflections about the Week 3 Challenge from Alchemy University #RoadtoWeb3.
This challenge is brought by Rahat, Lead Developer Relations at Polygon, so that’s why this project turns around this L2. I have taken advantage of the current momentum around the AU early pass to use it as the name of the project.
I have spent ~20 hours to get it done until I have finished it on the October 31, 2022. I love these kind of challenges as on every one of them I learn so many things that I would like to share with you in this post.
The big deal about this project is on exploring the possibilities of using SVG images for storing metadata attributes on chain in Polygon network. This is a use-case for a crypto game with users interacting several times per day with the Smart Contract in order to mint NFT, borrow them, train, feed, burn… or any other possibility that the game allow. All of these, with tiny $MATIC fees, rather than using directly Ethereum and its -sometimes- prohibitively high fees.
In terms of learning, now I can say that I have basic notions of:
Store NFT metadata on chain
Deploy to Polygon Mumbai
Edit xml on a SVG file. Link
Store a SVG file on-chain
Interact with the SC to modify metadata
Concept of decentralized random number generation in Blockchain. I really like the approach instead of being dependent of centralized algorithms.
Struct and mapping working together aka key-value array
Validate an SC in PolygonScan
Interact with a SC in PolygonScan
Use testnet.opensea.com. Tip: Don’t forget to click the Reload metadata button xD
Instead of using the concept of NFT warriors, I have created weapons. In concrete an AXE svg file with 3 attributes: Level, Weight and Strength.
Use another SVG file.
Create a ether.js file to test that the contract is working as expected in localhost
Create a burn function so in a future users could burn their weapons to get credit games
Create a randomize() function to manage the creation of random numbers on a defined threshold
Modify train() function in that way, a weapon will be trained for a random number from 0 to 5
Github:
Opensea:
https://testnets.opensea.io/es/assets/mumbai/0x5c3e09b1b9152731c962ff9a2befb91b1e06cfa6/3
Smart contract:
https://mumbai.polygonscan.com/address/0x5C3E09B1b9152731c962fF9A2Befb91B1E06cFa6
PoK address: 0x413afeea60152dfCf25637100B0Ab14470826Caa