Inspiration
One way to explore the potential applications of this emerging web3 space is by gaming because gaming is a leading indicator of up-and-coming technologies.
Having said that, we identified the following needs:
- The need for truly on-chain games.
- A scalable solution that doesn't compromise on the security and censorship resistance properties of the blockchain.
- The need for a thriving ecosystem and an addictive, irresistible setup with rewards and branding opportunities for web3 projects.
As a starter, we wanted to create a generalized framework for creating on-chain games that can handle private information or incomplete information games.
We wanted our architecture to run games off-chain by leveraging peer-to-peer communication and ensuring efficient and reactive gameplay without relying heavily on on-chain transactions. On-chain transactions will then only be needed when initiating the game, settling disputes, and recording final outcomes.
This strikes an optimal balance between privacy, scalability, and real-time interactions.
What it does
Currently, our ecosystem presents a samurai-themed game inspired by the classic rock, paper, and scissors game with an addictive reward pool set up along with presenting future prospects and intentions.
Every player can either choose to play this game against the CPU or against an actual player. Playing against the CPU is straightforward and has no critical flows associated with it.
If a player decided to play against a real player like him/her, the following actions need to take place in the described order:
- The player needs to stake a desired/minimum amount in order to play and this serves two purposes
- It serves as collateral, ensuring fair play
- It populates the reward pool
- The player then signs and posts a challenge, initiating a match-making process.
- Assuming the matchmaking was successful, both the players are connected over a p2p connection and the game starts. If matchmaking failed, the player has the option to retry.
- The players indulge in the game rounds and the player earliest to lose 5 rounds loses the game, thereby losing his/her share of the reward pool(earlier staked amount). The winning player gets everything from the reward pool minus 20%.
- The 20% value is added to our treasure pool
- The player who quits in between for whatever reason is deemed the loser
- The winning player needs to sign one last time to gain the rewards
Above all the players playing, we have created a tournament system where the top 5 players will be rewarded from the treasure pool at the end of every week. This incentivizes players to play even if the expected profit from a single match is negative
The ecosystem offers a game wallet to which all the deposits and withdrawals happen. The ecosystem is also open for every individual, brand, and gaming studio to publish their games by leveraging our infrastructure and system models.
How we built it
We first identified the core elements needed to accomplish the first iteration of our ecosystem and they are as follows:
- Game Net (a Trustless p2p system for on-chain games)
- Matchmaking service
- User interface / Frontend
We then defined each element and described how would it function and interact. This was followed by establishing a roadmap, goals, and a design system.
Game net & Contracts
We first started by defining the abstractions need for playing any private information games, Games can be thought of as a state machine. A game starts with an initial state, then players update the game state according to the rules of the game to ultimately reach a final state(s). We then devised a scheme for playing 2 player private information games over a p2p network using zk-proofs (proof of correct state transition).
- We used Circom to encode our game logic into a zk-circuit.
- The smart contracts are written in solidity.
- We created a weekly tournament system and used Chainlink's automation service to decentralize the process
- We deployed our smart contracts on the Sepolia testnet and we created an erc20 token (TST) that anyone can mint and test our game.
Matchmaking service
We came up with a scheme to match players which is sufficiently decentralized. To start a game, Players sign their intent to play a game, these intents (Match requests) remain valid only for a certain amount of time. Any other player can use it to start a game by doing an on-chain transaction. We then created a simple node.js server to facilitate the discovery process.
User interface & Gameplay
The entire user flow/experience was broken down into 2 core elements, namely the experience and features at the core of the product(web app in general) and the gameplay itself.
We first started by establishing the design system/theming for both the web app and the gameplay and started working on both simultaneously.
This was followed by establishing the layout and clearly defining our user flows for the web app as well as for our gameplay.
- We built the user interface using TypeScript and React alongside consuming other standard packages
- We used Tailwind and DaisyUI for our theme and styling and responsiveness
- We used ThirdWeb to interact and integrate with our smart contracts
- We accomplished our gameplay by creating the desired videos and audio which were rendered using video and audio html5 elements which were further integrated with controls and flows.
Challenges we ran into
We connected with each other for the first time and hence coordinating and communicating was a major challenge. At times, strongly sticking to the previously established commonly accepted way of implementation was also a challenge.
On technical grounds, one major challenge we ran into was the unavailability of needed features Space&Time. Originally for the tournament system, we planned to use Space&Time's sql query service along with their proof of SQL, to run complex queries, and create a more elaborate scheme for finding the tournament winners from the event data. but we ran into problems like their hackathon servers are not updated in realtime(only containing historical log data).
Accomplishments that we're proud of
We have a huge vision and we knew upfront that not everything will be accomplished by the end of this hackathon. Hence, we set the goal of accomplishing one major element without compromising on quality which would set the right foundation for future iterations and MVP and we are happy to have accomplished it irrespective of various ups and down.
What we learned?
A lot! Starting from how to collaborate effectively in a team to understand the nitty gritty of the technologies. Quick thinking and effective research to accomplish tasks within time. We learned to prioritize what's needed and effectively divide all tasks between all team members to finish a working dapp before the deadline.
What's next for Migawe
- Gain feedback on the existing system and incorporate them along with certain planned refactoring and optimizations.
- Complete the TODOs that got created along the way
- Build the branded version of the game and set up an easy and quick way to transform any game into a branded game.
- Establish control and configuration around the flow and reward pool of a game.
- Set up an efficient process for other game devs to use our system.
- Establish the plug-and-play framework.
- Introduce more games.
Built With
- chainlink
- circom
- css3
- html5
- javascript
- react
- snarkjs
- solidity
- tailwind
- thirdweb
- truffle
- typescript
Log in or sign up for Devpost to join the conversation.