Developing Dapp on Blockchain Using Reach: Liar's Dice!
Tags: react, blockchain
Published: 2021-10-06 00:00:29

Yuumi ADC joins the game with her Liar’s Dice! In this report, we’re going to go through the development process and future improvements. Good Luck, Have Fun!

#Game Introduction
Liar’s dice is a type of bluffing game. The object of the game is to bluff your opponents. You can play for fun, with money, or as a drinking game. Liar’s dice can be played by two or more players. but our version is a two-player game. After the users connect to their wallet, they can join the game center. They can either deploy a new game or join an existing one. Since the game itself needs every user to be completely honest (i.e. no secretly changing dice after the game starts), we decided to use the immutability of blockchain to accomplish this.
![Game Process](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pajtggg8997n6aorutl.png)

#Progress Report
Our time spent on each phase is evenly distributed. We mainly focused on the syntax of Reach in the early phase and gradually moved on to the interaction between Reach and our frontend. “Game Center” is a special feature we added to our game, which improves the efficiency for users. They no longer need to copy and paste the contract information, but instead use a four-digit code. This feature will be further introduced in the next section. When we first started on Reach, the learning curve was pretty steep because we spent a lot of time on reading the documents. After finishing the tutorial videos, we had significantly improved our understanding of the syntax of Reach as well as the background knowledge of blockchain. The [documentation](https://docs.reach.sh/) played a vital role in our development experience. Believe it or not, the [while loop](https://docs.reach.sh/guide-loop-invs.html) was one of our biggest challenges. We had some confusions between local steps and consensus steps, but the documentation did a great job explaining what they are and when to use them. We also referred to existing code pieces in past projects such as “[blackjack](https://bit.ly/3fxY0Ma)” from the [previous hackathon](https://youtube.com/playlist?list=PLPWjBm58kodOuEzkIScyf19PImKtflmKH); this gives us a better understanding of the overall logic and led to an overall improvement in code readability.
![Game Center](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wate0ylnikirvgib2my.png)
#Game Center
After we posted our demo, we received some compliments about our Game Center feature. Thank you so much for your support and interest! We decided to share the logic and operations behind this feature with all members of the community. You’re more than welcome to discuss them with us and make suggestions!
We raised an express server, which randomly generates a four-digit code when a new contract is deployed. This combination of data is saved in the server, allowing users to access the contract information by entering the code of an existing game. This improves efficiency because now they no longer need to manually enter the contract information to join a game! Note that after a user attaches to a contract or the contract experiences a timeout, the status attribute of the dict is switched to “used” and the game is taken down from the Game Center which can no longer be joined. Feel free to refer to [our code](https://github.com/Kevintjy/Reach/blob/master/bluffing/server.js) in GitHub.
#To Infinity
Even though this is a popular drinking game in China, there are several regional varieties and rulesets. Sometimes ones are not wild when they are called in a particular order (like two ones). We’d like to add a feature where people can select if they want to add their own rules before starting the game. We also like to expand this as a multiplayer game with more than one attacher.
For our next Reach project, we are planning to build a game similar to “Stardew Valley”, which provides a platform that gives users opportunities to explore and exchange items received in game. Our game account can be directly connected to the wallet, and each rare item gained in game can be created as an NFT pack. Users can either exchange the item in game, or sell the NFT on the Ethereum blockchain.
#And Beyond
Thank you so much for being with us so far! This is the first time we’ve participated in a hackathon. Initially, our goal was merely to learn about the blockchain. We’re flattered to achieve third place in this competition with worthy opponents. The friendly and enthusiastic learning environment made this experience all the more memorable. We believe blockchain is a promising emerging industry and we are looking forward to the future of Reach.
![Cover Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gp256y5te50fet9r5njz.png)
#About Developer
Both members of our team are senior computer science students attending the University of Toronto. We’ve developed web applications as well as projects related to machine learning and data management. This is the first time we’ve developed a dApp, and blockchain is a brand new realm for us. We believe the combination of blockchain and virtual currency is a rapidly growing trend and we look forward to learning in this community.
#Name
“Yuumi ADC” comes from a League of Legends champion Yuumi, the magical cat. She is ordinarily the support of each team and rarely has the ability to carry a game. We believe she can make the impossible possible and so can we!
#References 
1. Github Link: https://github.com/Kevintjy/reach
2. Video Link: https://www.bilibili.com/video/BV1H3411674C?from=search&seid=6784604523599943003&spm_id_from=333.337.0.0