How did I write my first Dapp in Reach?
Tags: dapps, smartcontracts, algorand, reach
Published: 2021-03-18 10:18:58

---
title: How did I write my first Dapp in Reach?
published: true
date: 2021-03-17 12:35:56 UTC
tags: dapps,smartcontracts,algorand,reach
canonical_url: https://medium.com/coinmonks/how-did-i-write-my-first-dapp-in-reach-9aa235ab4c90
---

### How did I write my first dApp in Reach?

![](https://cdn-images-1.medium.com/max/474/1*lMgoYCKnN3_zbb19Jk8igA.png)

I have been interested in blockchain for about three months now. At first, it was like a Pandora’s box; dApps, hashes, merkle trees, DAOs and many other words were thrown around. It frustrated me as a mobile app developer. The progress I made was very unsatisfactory compared to the time I invested.

Then I learned about [Reach](https://reach.sh/), a blockchain development platform claiming to be the “fastest, safest, and easiest way to build on blockchain”. Despite my initial skepticism, I decided to give it a try. The moment I finished the tutorial (having written my first blockchain application in two days) I understood: this was it. I could finally turn my ideas into functioning dApps.

Reach announced a “Bounty Hack” event in February to promote development of apps on the [Algorand](https://www.algorand.com/) network, strengthen its infrastructure, and introduce more programmers to Reach.

The following app I’m about to talk about is my submission to the Reach Bounty Hack, a hackathon event in which the primary goal is to encourage new developers to write their own Reach applications.

When I first heard about it, I had just finished the tutorial and had no idea how to build an entire application from scratch myself. Even though I wasn’t confident that I could finish it to the end, I decided to give it a try.

I hunkered down, diving into the documentation and tutorials; all the while, harassing Reach’s development team with an endless barrage of questions (_huge thanks to Jay, Chris, and Dan for being so patient!_). Mentors began to emerge within the community. Before long, _I_ became the one offering encouragement and support to the steady flow of newcomers writing programs in Reach. Five weeks later, my masterpiece was complete: a decentralized version of a first-gen Pokemon game called _“Pokéchain’’ in_ which players lock in their moves with a transaction. It ran on a Game Boy Advanced emulator_…_and Algorand.

![](https://cdn-images-1.medium.com/max/775/1*GPkdNhoTpDfxk5-8xdmXCA.png)<figcaption>A screenshot from my game</figcaption>

### **How it Works**

Pokéchain is an Algorand-based blockchain game where players commit their moves to the blockchain. Moves are played after being confirmed by consensus. Players pay a price for their move which is collected into a pool where it can either be transferred to the creator of that session or distributed among players following various rules.

> “Why Algorand”, you might ask.

> If you are familiar with Ethereum development, the answer is obvious: Algorand is much faster and cheaper on gas fees compared to what Ethereum offers. Gas and transaction fees for a simple game on Ethereum cost roughly 90 dollars. On Algorand, these fees are reduced to below two dollars.

### Big Surprises

Thinking back on the development process, I was surprised to realize that the easiest part of development was the blockchain part. Thanks to Reach’s abstraction of lower-level Solidity and TEAL code, a game which would normally take hundreds of lines to write in a complex developer environment took only 80 lines of code to write in Reach.

As programming languages go, Reach is relatively straightforward. It’s syntactically and semantically similar to JavaScript; apps are specified in JavaScript syntax. In many scenarios, the design logic Reach applies to contract participants made the coding process as simple as writing a script for the stage.

![](https://cdn-images-1.medium.com/max/400/0*BpoyOvtmhGZvC6OL)

I had some trouble building out the frontend because it was my first time writing a project for React & Node.js. I really struggled with state management because the nature of Dapp’s was hard to combine with a React app. That’s where my teammate, Namiq (sn#3348) came through with the clutch assist. He helped me style the pages and manage the states of the app.

Although we hit a few snags near the end, I’m much more comfortable writing React code and managing states in a dAapp now. Reach already supports any frontend _library_. From what I heard from the development team, Reach is going to support all frontend _languages_ soon (with the upcoming RPC server feature). As a Flutter developer, I’m very excited to see the direction Reach is going.

There is also code written in Python to play the Pokemon game when inputs are given. Those steps are just basic PyAutoGUI functionality combined with Requests library. I based the bot from the classic ‘Twitch Plays Pokemon” project which was also the starting point of “Algorand Plays Pokemon” (the project I was assigned in the Bounty Hack).

I was looking at a working version of my game after _just two weeks_ of development. Moments like this remind me how amazing it feels to be a developer. Seeing my idea come to life in such a short span of time, I can say with certainty that Reach makes blockchain development as easy as possible. Thanks to the simplicity of the code-base, it’s fairly easy to improve on what I’ve built so far.

![](https://cdn-images-1.medium.com/max/950/1*jgfRkOIQLJ6ltKEE-3TtKQ.png)<figcaption>The latest version of the game where you can input multiple moves at once</figcaption>

I am truly thankful to Reach for providing me with a platform for turning my ideas into well-functioning blockchain apps in a fast and easy way. I also want to thank the other Bounty Hack participants for voting for our dApp. We weren’t really expecting to win among the great projects other friends from the community have made. I can’t express enough how happy I am to have been a part of this.

If you’re not sure about writing your blockchain applications in Reach, my only suggestion is to at least [give it a try](https://docs.reach.sh/tut.html). I’m sure you’ll find more than I can explain in this short article.

If you want to see my game in action you can [check my video](https://drive.google.com/file/d/1vRFc-AYgdVUTZkJEr2uBugVBywkeGjGF/view?usp=sharing) explaining it.

You can also see the source code of the project [here](https://github.com/Zetsuboii/pokechain/tree/multipleMoves) in Github.

Thanks for reading and have a nice day!

* * *