Browser-Game with Solidity, JS, BSC, NodeJS, Hardhat , Chainlink
Tags: javascript, blockchain, gamedev, web3
Published: 2022-02-08 01:19:03

## The Crypto Purge 💸

The most revolutionary crypto shooter-survival real-time NFT-based game on **Binance Smart Chain.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oar4dsu7qv4rmo27df48.jpeg)

## Inspiration

`The Crypto Purge` is a crypto shooter-survival real-time NFT-based game inspired by [The Purge (an American dystopian action horror film).](https://en.wikipedia.org/wiki/The_Purge)

## What it does

Players will have multiple modes to play the game, `single` and `multiplayer`. **Single mode** includes killing zombies and social ranking with friends for earn prizes, the top scorers on the `leaderboard` will split the prize pool grant. **Multiplayer mode** allows players to contribute a certain amount of tokens to the prize pool before each game and the prize pool is split by `Smart Contracts` and a `Server Side authority` between the **winners** of the game. The game allow users to mint custom skins with **NFTs** to be used in the game (**Chainlink VRF** and Oracles to assign provably rare traits). Player will differ in appearance and style, but they will have no effect on the game mode. All players will have an equal change of winning the game.

## How we built it

`The Crypto Purge` has a crypto integrated backend that runs on **Binance Smart Chain. Smart contracts** are responsible for prize pool redistribution and **web3.js (Metamask, etc)** takes care of the wallet connection. We built the app using ReactJS, Phaser Framework, Hardhat with Chainlink Oracles for smart contracts development and NodeJS with Express Framework using Socket.io for real-time connections.

## Challenges we ran into

Creating a **decentralized real-time** game that requires a back-end connection using `WebSockets` is the most challenging part of the project, additionally because **"don’t trust the player. Always assume the worst – that players will try to cheat"**, so it requires an `authority server` to create a **cheat-proof** architecture as cheating players tends to drive the players away from the game, therefore the core problems are `human nature` and `physics`.

Developing an `authoritative server architecture` introduce a whole new class of challenges; `Client-Side Prediction`, `Server Reconciliation`, `Entity Interpolation`, `Lag Compensation` dealing with networks and scaling the system itself.

## Accomplishments that we're proud of

We're proud to have created the real-time connection of the game, creating the smart contracts of the platform and the base architecture of the project; **front-end, back-end** and the smart contracts development using **Hardhat** with **Chainlink Oracles**.

## What we learned

We learned about `Blockchain`, `Smart Contracts`, `NFTs`, `Chainlink Oracles`, `2D Games` with `WebGL/Canvas` using Frameworks like `PhaserJS`, `Physics`, `Real-time` connections with `WebSockets`, `Crypto wallets` and much more!

## What's next for The Crypto Purge

Allow gamers to edit their profile.
Open Marketplace to buy and mint custom skins.
Allow gamers to mint weapons and other assets.
Allow gamers to have an inventory.
Add a better configuration for the monorepo and create a Docker image with the configuration to run the project anywhere.
Use Microservices strategy for complex calculations and horizontal scaling, To infinity and beyond!
Share the end results and inspire others with Open Source contributions.

Built With
`alchemyapi`,`blockchain`,`canvas`,`chainlink`,`css3`,`ethers`,`express.js`,`github`,`hardhat`,`heroku`,`html5`,`javascript`,`phaser.js`,`react`,`socket.io`,`solidity`,`web3`,`webgl`

[GitHub repo](https://github.com/proyecto26/TheCryptoPurge)

Made with ❤️ by [Luis Lucena](https://bio.link/luislucena) and [J.D Nicholls](https://bio.link/jdnichollsc)

Twitter: [Luis Lucena](https://twitter.com/_luisald) and [J.D Nicholls](https://twitter.com/jdnichollsc)