Link: https://crypto-racers.web.app
Inspiration:
The inspiration for our project Crypto Racers was Namco's pole position. Pseudo 3d racing games have an excellent mix of nostalgia and immersion.
What it does:
Crypto Racers allows users to go head to head against each other with their own ERC721 cars. Each race has an entry fee of a specified amount of our ERC20 RACER tokens. Win the race? All deposits go to you. Lose the racer? Better luck next time! Users can save up their RACER tokens to upgrade their car's speed, acceleration, torque, drift, and weight. Once they achieve their perfect car, they have the ability to dominate the competition with it, or sell it on our marketplace for more RACER tokens, or MATIC.
How we built it
The main functionality of Crypto-Racers runs on three separate smart contracts. To start, Racer.sol operates as our storage and calling contract. Next, RacerUtils.sol receives calls such as minting request and token upgrades from Racer.sol. Completing all gas-heavy computation and calculation, it then writes the results back to the calling contract. Finally, RacerToken.sol operates our ERC20 functionality, and maintains the Crypto Racers economy.
But how do we run this smart contract functionality back to the user? Lets start from the beginning. When a user first connects their wallet they are greeted with a request to sign a message to authenticate themselves. This process runs off of Thirdweb JWT authentication system. Moving on, to read data from out RacerStorage contract, we used the Thirdweb SDK to get the fastest response times as possible. This is how we load and display the users Racer Tokens and NFT's along with their statistical information right off the blockchain. Along with this, we are using the sdk to connect to our payable and state modifying functions in order to update game data as needed.
Moving into the game side, we used Unity along with Thirdweb gaming kit. We used the gaming kit to communicate token and user data needed for a prerace, along with making calls and inserting data back into the blockchain such as winner payouts and token statistical increments/decrements.
Challenges we ran into
Our team faced two major challenges throughout the course of this hackathon; Smart contract OOP and Multiplayer Matchmaking. For smart contract OOP, it was very tough to pick the correct design pattern in order to minimize the users need for signing transactions and gas payments. Through trial and error we ended up opting for a factory model. Moving onto matchmaking, writing and communicating data all on server side systems was tough. Unfortunately this still needs some fine tuning, and will be the first thing to perfect in the future.
Accomplishments that we're proud of
The team is proud of making the first strides to having statistical game data on chain, and receiving that data in time efficient manners.
What we learned
Our team successfully learned how to authenticate web3 users, the process that brings security to a space that arises worries in that department. On top of this, we learned the vast potential of web3 gaming, and all look forward to being builders in this space as time goes on.
What's next for Crypto Racers
In the upcoming months, we plan to add new levels, customizations, and further improve the design of Crypto Racers.
Log in or sign up for Devpost to join the conversation.