Day 7 of "Building an Equipment System with Smart Contracts" for @ethgardlegends.
Imagine you find a cool sword and want to equip it to your hero to gain benefits in the game. That's what I'm building.
In technical terms, the goal is to allow NFTs (ERC1155/ERC721) to be equippable on other NFTs (ERC721 => Heroes).
Today's progress:
Started the day by continuing work on the UI for the equipment system.
While refining the flow, I realised that equipping and unequipping items aren't really two separate actions - they're optimally one single operation.
So I refactored some of the smart contract by removing equipItems/unequipItems in favor of a single changeEquipment function, which takes both the items to equip and the slots to unequip.
Once that was in, I hooked everything up, made some code-magic, and was finally able to equip items onchain for the first time.
In the video below, I'm equipping a Rare ERC1155 Skin and an ERC721 Sword/Shield onto an ERC721 Hero. Items can be equipped/unequipped by dragging as well as right-clicking on them.
Finally, I also added some simple tooltips when hovering over the items. With that, the full core flow is now working. Next up are further improvements, polishing, and getting things production-ready. Check out the demo video:
Today's lesson:
Slow and steady wins the race.
When I first started working on this, the whole thing felt like a huge mountain. I remember thinking, “how the heck am I gonna get all this done?” Now, just a week later, I’m on that mountain, and while I see another one up ahead, I can also look back and appreciate the climb (work) so far.
Just keep on coding.
PS: If you're having trouble understanding certain parts but want to learn more, try the AI feature on Peakd or ChatGPT/Grok to have it explained 👍.
Congratulations @therealwolf! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Check out our last posts: