0xFableOrg / 0xFable

A fully on-chain trading card game. There will be elves, wizards & shit. Drama and broken friendships also.
https://twitter.com/0xFableGame
BSD 3-Clause Clear License
103 stars 35 forks source link

Bring custom decks onchain #103

Open eviterin opened 6 months ago

eviterin commented 6 months ago

Right now, the deck editor is saving the deck locally in-memory - see webdev/src/_app.tsx. Instead, we would like to save the deck on-chain. There seems to be functionality already in place for this that is being used by contracts/src/DeckAirdrop.sol & webapp/src/hooks/useFableWrite.ts.

It also makes sense for the player to be able to name their decks, but the data structure for a deck is just a set of card - not including a name.

This is done when:

eviterin commented 6 months ago

If someone could assist on the contract side and give some directions on how to hook on to that from the front-end I'd be happy to collab.

norswap commented 6 months ago

There's two parts: reads and writes.

For writes, you can follow the patterns in the actions package and use libContractWrite.ts to make calls.

For reads, we could a bit of architecturing to avoid excessive data fetches, but let's keep things simple for now. You can use the wagmi autogenerated React hooks, here's an example of such from the collection page.

Regarding which contract functions to call, it's all in the Inventory contract., it should be pretty self-explanatory (addCard, getDeck, etc)

You might need to modify those and the Deck structure to add deck names saved on the blockchain.

Don't hesitate to hit me up if you have any question!