Day 1 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 items (ERC1155/ERC721) to be equippable on ERC721 tokens (i.e., Heroes). --- ### Today's progress: Started designing the logic and data structure for the new contract and named it InventorySystem. Had to figure out the category for the items and the available slots, i.e., Main Hand, Off Hand, Head, Shoulder, Chest, Fingers, etc. Continued developing the code for equipping/unequipping items and initially chose the existing ERC1155 contract for the new items (Weapons, Armor, Accessories). After writing the tests and having a working first version, I realized that the items needed to be ERC721 instead - allowing for different stats, enchantments, durabilities, and more per item. This led me to create another ERC721 contract, ItemSystem, along with new data structures for these ERC721-based game items. The items can so far be Weapons, Armor, or Accessories. The base code has been written, including the logic for minting these items (via Signature). Existing test logic will need to be refactored a bit due to the items now being ERC721 instead of ERC1155.  --- ### Todays lesson: When developing smart contracts, it's critical to find a good balance between designing for future use cases and keeping it simple. In this case, I decided against making the contract highly generic, as it would create unnecessary complexity and overhead. Instead, I focused on the three main ERC721 items: Weapons, Armor, and Accessories. Another lesson is that it's better to refactor existing code if the design pattern could be improved - even if the tests are already written and working. Once the contract is live, even with upgradeability, modifying anything related to storage is either impossible, risky or requires migration. So, better to think twice while still keeping it simple. --- _PS: If you're having difficulties understanding certain parts but would like to learn more, try the AI feature on peakd or chatgpt/grok to have it explained 👍._
author | therealwolf |
---|---|
permlink | building-in-public-day-1-of-a-smart-contract-based-inventory-system |
category | buildinginpublic |
json_metadata | "{"app":"peakd/2025.3.5","description":"Starting with some passing tests. Green is good!","format":"markdown","image":["https://files.peakd.com/file/peakd-hive/therealwolf/23tRzWNoQQZR5nAt3TEk9twPS1uq5vfanGd3wboyM8AvXL9zVnshSARg5rjdSTYyETvYP.png"],"tags":["buildinginpublic","ethgardlegends","evm","smartcontracts"],"users":["ethgardlegends."]}" |
created | 2025-03-24 22:46:30 |
last_update | 2025-03-29 22:29:27 |
depth | 0 |
children | 0 |
last_payout | 2025-03-31 22:46:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 5.627 HBD |
curator_payout_value | 5.608 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,349 |
author_reputation | 581,693,011,827,252 |
root_title | "Day 1 of Building an Equipment System with Smart Contracts (Solidity)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 141,657,541 |
net_rshares | 33,001,598,680,082 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
daan | 0 | 215,374,412,749 | 30% | ||
sharker | 0 | 18,266,468,738 | 45.5% | ||
kibela | 0 | 2,565,883,866 | 50% | ||
borran | 0 | 1,185,799,358,904 | 100% | ||
penguinpablo | 0 | 140,306,397,179 | 14% | ||
funnyman | 0 | 1,424,354,135 | 5.6% | ||
steemcleaners | 0 | 1,820,526,741,599 | 80% | ||
ssekulji | 0 | 264,303,112,364 | 100% | ||
bleujay | 0 | 3,092,565,282,219 | 100% | ||
jaybird | 0 | 5,101,870,857 | 100% | ||
driptorchpress | 0 | 41,494,476,781 | 25% | ||
diggndeeper.com | 0 | 7,390,222,719,539 | 100% | ||
smasssh | 0 | 1,393,920,817,317 | 30% | ||
svinsent | 0 | 83,223,008,187 | 52% | ||
uruiamme | 0 | 8,174,159,433 | 70% | ||
aleister | 0 | 9,132,616,163 | 10% | ||
alainite | 0 | 2,027,659,504 | 100% | ||
masterthematrix | 0 | 30,269,493,323 | 100% | ||
alphacore | 0 | 7,019,822,970 | 7.12% | ||
freddbrito | 0 | 13,209,881,720 | 80% | ||
spectrumecons | 0 | 1,806,100,084,343 | 25% | ||
offoodandart | 0 | 7,911,041,509 | 100% | ||
rival | 0 | 12,343,501,833 | 100% | ||
joeyarnoldvn | 0 | 519,524,185 | 1.66% | ||
heyitshaas | 0 | 12,767,799,957 | 100% | ||
eturnerx | 0 | 21,162,683,046 | 1.6% | ||
duremarr | 0 | 13,360,212,168 | 50% | ||
vikisecrets | 0 | 840,451,432,382 | 33% | ||
investingpennies | 0 | 304,753,128,903 | 100% | ||
yacobh | 0 | 11,632,634,269 | 70% | ||
thelordsharvest | 0 | 35,396,362,567 | 100% | ||
arquiatra | 0 | 2,442,041,605 | 100% | ||
fatman | 0 | 9,213,835,016 | 2% | ||
votehero | 0 | 21,517,303,789 | 4.3% | ||
gnarlyanimations | 0 | 1,821,237,612 | 100% | ||
espoem | 0 | 111,093,716,393 | 35% | ||
meno | 0 | 2,096,709,847,105 | 100% | ||
gringo211985 | 0 | 2,753,959,235 | 100% | ||
vegoutt-travel | 0 | 28,766,214,684 | 25% | ||
macmaniac77 | 0 | 23,672,495,435 | 100% | ||
pangoli | 0 | 1,287,510,183 | 100% | ||
lays | 0 | 4,279,392,848 | 100% | ||
flamo | 0 | 559,287,035 | 50% | ||
craigahamilton | 0 | 513,729,269 | 5% | ||
mytechtrail | 0 | 17,677,135,554 | 15% | ||
prometehum | 0 | 1,041,370,202 | 100% | ||
nathen007 | 0 | 496,275,740,432 | 100% | ||
spiritabsolute | 0 | 37,927,647,930 | 100% | ||
cryptonized | 0 | 236,207,600 | 14% | ||
hooiyewlim | 0 | 5,634,671,208 | 100% | ||
steemvault | 0 | 44,201,554,209 | 100% | ||
steem4all | 0 | 8,836,114,692 | 50% | ||
communitybank | 0 | 73,961,964,940 | 100% | ||
gandhibaba | 0 | 566,847,669 | 100% | ||
utube | 0 | 74,087,618,222 | 100% | ||
jigstrike | 0 | 16,599,789,758 | 50% | ||
socialmediaseo | 0 | 1,027,016,068 | 50% | ||
soyrosa | 0 | 392,351,962,019 | 50% | ||
videosteemit | 0 | 36,706,810,845 | 100% | ||
fantasycrypto | 0 | 75,450,504,962 | 100% | ||
gavinatorial | 0 | 955,039,629 | 100% | ||
cryptosharon | 0 | 179,213,663,597 | 100% | ||
photohunt | 0 | 60,763,855,420 | 100% | ||
photohunter1 | 0 | 2,418,017,281 | 100% | ||
photohunter2 | 0 | 2,296,469,030 | 100% | ||
photohunter3 | 0 | 1,527,932,684 | 100% | ||
photohunter4 | 0 | 1,572,523,295 | 100% | ||
photohunter5 | 0 | 1,635,581,893 | 100% | ||
mindscapephotos | 0 | 912,983,091 | 100% | ||
asgarth | 0 | 842,003,576,648 | 50% | ||
cst90 | 0 | 470,661,561,375 | 100% | ||
movement19 | 0 | 13,024,122,635 | 45% | ||
photobook | 0 | 15,415,652,841 | 100% | ||
superlotto | 0 | 103,931,400,921 | 100% | ||
olgadmitriewna | 0 | 2,587,585,970 | 100% | ||
patlu | 0 | 820,322,698 | 20% | ||
sunshinebear | 0 | 1,601,546,144 | 50% | ||
steemitcolombia | 0 | 4,335,573,173 | 100% | ||
bil.prag | 0 | 123,098,907,745 | 12% | ||
vcclothing | 0 | 161,530,060,252 | 100% | ||
rivalzzz | 0 | 159,028,306,699 | 100% | ||
franciscopr | 0 | 30,368,157,405 | 100% | ||
z3ll | 0 | 2,448,422,370 | 100% | ||
petertag | 0 | 10,546,081,674 | 100% | ||
fw206 | 0 | 850,902,239,898 | 10% | ||
valentin86 | 0 | 30,762,781,333 | 100% | ||
pladozero | 0 | 11,522,649,269 | 10% | ||
nateaguila | 0 | 177,514,076,253 | 12% | ||
steem-tube | 0 | 8,014,602,262 | 100% | ||
fernandosoder | 0 | 11,136,203,047 | 100% | ||
steddyman | 0 | 2,461,124,789 | 100% | ||
solarwarrior | 0 | 63,928,630,526 | 100% | ||
citizendog | 0 | 36,120,457,547 | 100% | ||
thedailysneak | 0 | 493,954,370 | 0.59% | ||
yestermorrow | 0 | 12,128,938,043 | 31% | ||
fandelkefir | 0 | 4,088,296,636 | 100% | ||
orthodoxnudism | 0 | 6,399,282,035 | 75% | ||
goingbonkers | 0 | 33,483,304,083 | 50% | ||
voxmortis | 0 | 38,302,599,022 | 20% | ||
steemitcentral | 0 | 285,321,939,731 | 100% | ||
voter001 | 0 | 21,635,047,045 | 22.9% | ||
pet.society | 0 | 14,943,644,316 | 6% | ||
steemituplife | 0 | 654,456,242 | 25% | ||
sbi9 | 0 | 61,318,838,331 | 19.36% | ||
thrasher666 | 0 | 2,561,403,619 | 60% | ||
mistia | 0 | 7,049,627,571 | 100% | ||
carbodexkim | 0 | 823,294,194 | 100% | ||
cakemonster | 0 | 55,361,301,928 | 100% | ||
nikollettesunday | 0 | 50,721,976,063 | 100% | ||
jacuzzi | 0 | 606,034,159 | 1.4% | ||
steemstorage | 0 | 129,614,850,144 | 100% | ||
fire451 | 0 | 2,238,870,265 | 100% | ||
starfighter | 0 | 5,153,125,916 | 100% | ||
seekingalpha | 0 | 783,891,763 | 100% | ||
caribehub | 0 | 1,381,469,491 | 100% | ||
broxi | 0 | 18,627,871,280 | 75% | ||
smallboost | 0 | 99,383,799 | 100% | ||
goodcontentbot | 0 | 806,693,835 | 15% | ||
realgoodcontent | 0 | 976,540,832 | 100% | ||
peter-bot | 0 | 687,984,675 | 100% | ||
hungrybear | 0 | 620,403,738 | 14% | ||
babschnae | 0 | 6,781,491,520 | 2% | ||
wolffeys | 0 | 12,167,062,779 | 100% | ||
davidtron | 0 | 3,187,792,944 | 50% | ||
mind.force | 0 | 3,437,710,317 | 25% | ||
lrekt01 | 0 | 6,417,489,153 | 80% | ||
hyborian-strain | 0 | 2,435,944,017 | 30% | ||
tokensink | 0 | 65,253,168,118 | 100% | ||
beta500 | 0 | 75,051,691,755 | 100% | ||
knightsunited | 0 | 17,198,879,836 | 100% | ||
sbi-tokens | 0 | 923,346,688 | 1.18% | ||
liaminit1 | 0 | 7,098,188,240 | 90% | ||
bilpcoinbot | 0 | 4,194,320,537 | 100% | ||
gmlrecordz | 0 | 712,945,273 | 50% | ||
garlet | 0 | 37,811,520,829 | 50% | ||
dec.entralized | 0 | 20,996,146,212 | 100% | ||
hive-127039 | 0 | 669,399,955 | 25% | ||
tht | 0 | 11,319,020,978 | 100% | ||
thepeakstudio | 0 | 3,204,745,052 | 100% | ||
captainhive | 0 | 663,290,658,015 | 25% | ||
woelfchen | 0 | 39,951,535,902 | 10% | ||
greengalletti | 0 | 3,873,248,341 | 100% | ||
recoveryinc | 0 | 59,517,420,574 | 90% | ||
liz.writes | 0 | 1,948,107,219 | 90% | ||
dying | 0 | 3,431,406,286 | 90% | ||
adedayoolumide | 0 | 738,505,918 | 100% | ||
loulou1987 | 0 | 63,610,336,610 | 100% | ||
samrisso | 0 | 35,558,081,759 | 50% | ||
trostparadox | 0 | 4,170,135,470,677 | 100% | ||
xyba | 0 | 43,616,768,871 | 100% | ||
mrhoofman | 0 | 4,229,922,966 | 25% | ||
farpetrad | 0 | 85,842,273,542 | 100% | ||
menzo | 0 | 5,582,837,960 | 10% | ||
snaqz | 0 | 507,744,132 | 100% | ||
relf87 | 0 | 41,394,105,980 | 50% | ||
bravetofu | 0 | 900,954,262,731 | 100% | ||
cimmeron | 0 | 27,461,146,822 | 100% | ||
hive-152804 | 0 | 43,807,179 | 100% | ||
archives-upfunds | 0 | 40,532,542,869 | 100% | ||
daudmuhammad2022 | 0 | 259,108,690 | 96% | ||
fee-service-new | 0 | 7,502,815,483 | 100% | ||
atf-sentinel | 0 | 2,270,105,605 | 100% |