Skip to content

A real-time multiplayer backend for a Crypto Crash betting game built with Node.js, Express, WebSocket, and MongoDB. Players place bets with BTC/ETH, watch the multiplier grow, and try to cash out before the game crashes!

Notifications You must be signed in to change notification settings

sanjaykumar200599/BitRush

Repository files navigation

Frontend url: https://crypto-crash-backend.vercel.app/

Backend url: https://crypto-crash-backend-m4w8.onrender.com/

🎮 Crypto Crash Game (Backend)

Below api endpoint is created in postman.

user_id: 688b57d79a5c82fc9b343799
name :king
IMP : Please use the above user_ID instead random_ID for testing purpose, use this in front end deployed link, also run backend url first then move to frontend url.


A real-time multiplayer backend for a Crypto Crash betting game built with Node.js, Express, WebSocket, and MongoDB. Players place bets with BTC/ETH, watch the multiplier grow, and try to cash out before the game crashes!

🚀 Features

  • 📈 Real-time multiplier updates via WebSockets
  • 🎲 Provably fair crash algorithm
  • 💵 USD-to-crypto conversion using live Binance prices
  • 👤 Player wallet and balance management
  • 🧾 Transaction history for bets, cashouts, and losses
  • 📊 MongoDB models for players, rounds, and transactions
  • 🔐 Secure cashout logic that rewards only pre-crash exits

🛠️ Tech Stack

  • Node.js with Express
  • MongoDB with Mongoose
  • Socket.IO for real-time communication
  • Binance API for live crypto prices
  • Crypto module for provably fair logic

Images:

Bet placed: Image

After Cashout:

Image

🗂️ Project Structure

crypto-crash-backend/

├── server.js

├── .env

├── config/

├── models/

|__ public/

├── services/

├── routes/

├── middleware/

├── sockets/

├── utils/

├── public/

├── scripts/

├── docs/

🧪 Run Locally

1. Clone the repo

git clone https://github.com/sanjaykumar200599/Crypto_crash_backend.git
cd Crypto_crash_backend
  1. Install dependencies
npm install
  1. Configure Environment Create a .env file (if needed) or ensure the following values are set:
MONGODB_URI=mongodb+srv://<your_connection_string>
PORT=3000
You can also configure crash constants in /config/constants.js:
  1. Run the server
node server.js

🌐 WebSocket Events Event Direction Description

place_bet Client → Server Submit a bet

cash_out Client → Server Request to cash out early

round_start Server → Client New round begins

multiplier_update Server → Client Multiplier increases

round_end Server → Client Round ends (crash point hit)

player_cashed_out Server → Client Broadcast when player exits early

About

A real-time multiplayer backend for a Crypto Crash betting game built with Node.js, Express, WebSocket, and MongoDB. Players place bets with BTC/ETH, watch the multiplier grow, and try to cash out before the game crashes!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors