Day 8 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 giving both the Equipment and ERC721 Items smart contracts a bit of polish and deploying new versions. They should be production-ready at this point.
Next up: looked into adding stats for ERC1155 items. In this case, I wanted to introduce a LUCK
stat to skins, which would increase the rewards earned in battle.
Unlike ERC721s, which have unique metadata per token, ERC1155s are semi-fungible — so stats need to be stored within the blueprint, not per individual NFT.
You could store this offchain, of course, but since the goal is to have as much logic via smart contracts as possible, it’s all being stored directly onchain.
Since skins and other ERC721/ERC1155 items exist in multiple rarities (and potentially levels), I needed a system that could scale. That meant figuring out a fair and flexible stat budget per item. I did quite a bit of research for this part. The current system isn’t finalized yet, but for LUCK
specifically, I decided to store it as a value between 1 and 10000 - essentially simulating a float where 10000 = 100.00%
and 1 = 0.01%
and having a multiplier of 1.5 to 1.7 between rarities.
After updating the indexer and backend infrastructure to support this, I switched over to the frontend and started designing the initial version of the stats overview per hero.
If you’re wondering why the hero isn’t holding a sword or shield - it’s simply because I haven’t minted those yet on the new version of the contract.
Today's lesson:
Research, baby.
When building smart contracts, it’s worth taking the time to plan ahead. Not everything has to be used from day one - but doing the research and designing systems that are general enough can save you from painful migrations later on.
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 👍.
I have no idea how the game is being built. But I'll support that it's using an engine (ignore if it doesn't have one).
In that case, could you evaluate some pre-ready options for Web3 on platforms like Thirdweb and Sequence SDK, or even Moralis?
It's not using an engine for Web3 integration. Mostly custom solutions based on OpenZeppelin smart contracts and some Thirdweb contracts.
I looked into all 3 though (Thirdweb, Sequence and Moralis). Either one would probably be fine. I'd prefer Thirdweb or Sequence.
You can also go for custom + indexer (i.e. https://ponder.sh/), as this will replace your need for using a thirdparty to get contract data - i.e. NFTs & co.
Wow that's super cool! I looked at those 721 standards and wondered what possibilities there could be. ERC1155? I should look at this more. ["uses a single smart contract to represent multiple tokens at once."]
721 are non-fungible tokens, while 1155 could be fungible or non-fungible, but are mostly used for fungible game items. The advantage of 1155 is that it's much more efficient to transfer many of them, in contrast to 721, where you'd need to do multiple single transfers.
The overall advantage of standards like erc721 and erc1155 is that they're supported across the ecosystem.
I have a lot of big ideas but am overly cautious about implementing them. I appreciate your explanation and I will keep an eye on your progress here.
Yesterday I was just checking on the witnesses that I vote for to make sure they are still active and their nodes are working. Thanks for helping to keep Hive running smoothly!