Inspiration

A simple Earn to play the game. In this, the users have bet on two different token pairs. Whoever wins the bet, the pool money is divided into it. The main inspiration was to build on a blockchain-based game and use the capability of chainlink products like data-feeds and keepers to automate most of the work.

What it does

Just choose any one of the coin whose price will fluctuate more in a given time. One with a higher percentage, whether up or down will win.

To play now on testnet, you need to have a matic testnet account and connect with it. https://crypto-price-pair-prediction-game-qyfzhwjus-suraj975.vercel.app/

  1. Bet Any Coin Pair Bet on any coin pair (eg: ETH/USDT) which you think will have greater price fluctuation within the given time.

  2. Wait for the round completion Once the draw is over, the coin pair with the highest percentage change wins.

  3. Claim Rewards If you win the bet then click claim to get the rewards

    How we built it

    The first thing was to write a contract which will capture the user details, and user rounds, and calculate rewards. This contract was built on solidity and deployed on the polygon test net for lower transaction fees.

To create a Web UI for the user to perform actions as per the game rules. For this, React was used to built the UI and metamask for blockchain transactions.

Challenges we ran into

The game look simple but there were a lot of things that had to be handled from capturing data, calculating rewards, automating multiple rounds in solidity contract and effectively updating the web UI in real-time.

  1. There was a lot of data to be captured for this game to play. Using proper variables and mapping to segregate different data on solidity for optimal usage of gas fees.

  2. Rather than running a backend server to handle all the round completion and user rewards. Chainlink keepers were used to handle multiple rounds of different coin pairs. The game does not have only one round, but it has multiple rounds and handled everything from keepers. There were several issues in using keepers on the eth chain due to proper requirements required to run it on the eth chain and the cost was too high to run it on keepers. That's the reason polygon chain was used as the transaction cost was way low.

  3. On the frontend part, the most challenging part was to listen to events of multiple rounds being executed and users' actions that require the UI to update quickly in real-time with new blockchain updated data. The data like the round end, user collecting rewards, and new round adding in the UI.

Accomplishments that we're proud of

Building a game on blockchain and automating a lot of things on the contract with the help of chainlink. This didn't involve any backend and the majority of the part was handled by the chainlink keepers.

What we learned

  1. Writing solidity contracts.
  2. Different ways of optimally creating to contract to use low gas fees.
  3. Automation and off-chain data usage on the blockchain with the help of chainlink.
  4. The true power and benefits of blockchain technology.
  5. There were a lot of issues and bugs which help me understand the solidity language in a much deeper way.

What's next for Crypto Prediction Bet

  1. This needs to be deployed on the matic mainnet as the current chainlink price feeds on the test-net take more than 1hr to 24 hours to update the coin prices. On the mainnet the price changes update every few seconds which will make the game have shorter rounds and increase the chance of more winning.

  2. Require design changes to make it more user friendly and appealing.

  3. Using proxy contract or other ways to update contract once deployed.

Built With

Share this project:

Updates