We built a fully on-chain autonomous world of cards where two players fight with each other. Our game is inspired by Hearthstone to some extent. Enforcing by code, we introduce rules as follows. Two players can freely compose their decks by drawing from three types of cards: warrior, wizard, and tanks. They can fight with each other by displaying cards and giving orders to cards for attack and defense. A player loses once his/her HP is less than zero. We make this game fully on-chain without any centralized servers so that it is an autonomous world and no one can ever shut it down, even us as developers.
We start with a zkShuffle SDK developed by p0x labs for fair on-chain card shuffling and dealing. Then, we wrote Solidity code for game logic and deployed it on the Optimism Goerli Testnet. We integrated with NFT.storage to store our cards as NFT for decentralized storage. Finally, we used NPM, Yarn, and Typescript to write our front-end. We also used stable diffusion to generate card images for warriors, wizards, and tanks.