Racecourse is a horse racing game implemented as a decentralized application. The front end is built using React and Redux. The back-end is built on NodeJS. Communication between the front-end and the back-end is carried out using Socket.io. The game itself is implemented as a smart contract written in Solidity.
Click here to view the smart contract source code.
Before running the sample, make sure you have a Kaleido environment with at least one node. For this sample we recommend using Quorum-RAFT. Steps to setup an environment can be found here. Also, create a set of application credentials, instructions for this can be found here.
- Trying out the sample application on Glitch
Glitch is a free platform for running web applications. Click on “Remix this” to open a new browser tab and from there click on “Show” in the upper-left corner.
- Trying out the sample locally
Make sure to have Node.js installed. Clone the Racecourse GitHub repository then run “npm run start”.
Connecting the sample to the blockchain
Once the sample application has started, type in the node URL and application credentials in the login screen. The sample will automatically deploy a new contract if the input field for the contract address is left blank.
- Players must place bets by selecting a race horse and an amount.
- No more than one bet per player is allowed in each race.
- Once the bet is placed, players get to choose when they are ready to race.
- Players may choose to race immediately or wait for others to join.
- When all players are ready, the race takes place and the winning race horse is announced.
- If one or more players had bet for the winning race horse, the jackpot will be distributed equally among them.
- If there are no winners, the jackpot is carried over to the next race.