The game for AU Early Pass Battle

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.

Learnings:

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

Challenge Improvements:

  • 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

How does the NFT looks like:

Minted Axe after two trainings
Minted Axe after two trainings

PoK address: 0x413afeea60152dfCf25637100B0Ab14470826Caa

Subscribe to Looppah ⚡️🐙
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.