Day 9 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 debugging some issues around smart contract indexing. Turns out that when the ABI differs slightly after upgrading a contract (new version deployed via proxy), the indexer doesn't always pick it up. After switching to the latest ABI, everything started working again.
From there, I continued the research from yesterday around stat budgeting and scaling. The core idea is figuring out how stats like armor, strength, agility, etc. should progress based on item level, rarity, and defined min/max values.
With that in mind, I updated the logic for stat generation. The system now generates the corresponding metadata with randomized stats based on a predefined scale or algorithm. For example, a Cloth Robe with itemId = 13
, equippable to the Chest would have a higher minimum armor value compared to Cloth Gloves with itemId = 16
, equippable to the hands. However, because there's also a max value, you might get lucky and roll gloves with better armor than a low-end chestpiece.
I also aggregated all stats for equipped heroes and updated the UI to reflect them. To test it out, I minted a few items with random stats and equipped them. The result speaks for itself - see the video below.
https://x.com/thewolfonchain/status/1907549472235905166
Today's lesson:
Get practical.
When I first set up the item structure, I figured rarity could live inside the blueprint—so itemId 30 could represent a Common version, 31 an Uncommon, and so on. But after working more on stat scaling and actually testing things out, it became clear that it’s way more practical to define rarity per NFT rather than per blueprint.
Some decisions only become obvious once you get hands-on. Getting practical is a big part of good design, at least in my work-flow.
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 👍.