Skip to content

Dodging-Turtis/Dodging-Turtis

Repository files navigation

Dodging Turtis

Turtis

Dodging Turtis is an NFT based game which runs on the POLYGON network in the Ethereum Blockchain and is powered by decentralized Chainlink Oracles.


Turtis

About the project

The game involves a Turtle character who dodges through the platforms coming towards it with increasing speed. The NFT here is the Turtle character. Everytime a row of blocks are dodged by the turtle, 10 points are added to the score. The current game is over when the Turtle collides with any of the platforms.

Inorder to dodge through the blocks, the Turtle can move left or right using the arrow keys. The speed of the left and right movement of the Turtle varies for each Turtle NFT. The game is really fun to play and it can get really challenging as the speed of the platforms increase with time.

Turtis

The player is rewarded with a new random Turtle NFT everytime a new checkpoint score is reached by the user. The checkpoint score is atleast 110 more than the previous high score of the player.

Turtis

Higher the score achieved for a new checkpoint, higher the speed of the NFT character that the user receives as a reward. More speed allows the player to move faster through the platforms and reach high score easily. Users would want to own NFTs with higher speed and hence it acts a selling point.

The NFTs are dynamic. Every new Turtle NFT has a unique name, randomized image and a random speed which is ranged according to the score achieved by the user. ERC721 standard is used for implementing the NFT. The symbol the Turtis NFT token is TRTL.

Some of the randomly generated Turtles are as follows:

Turtis

Turtis


Turtis

The metadata for the NFT is stored in FlieCoin and IPFS using nft.storage using the Custom API and it returns the IPFS Hash to the smart contract using Chainlink Oracles.

center

The DApp(Decentralized Application) which includes the Game is deployed to the MATIC Mumbai Testnet

Users can select any Turtle from the Turtles they own and play the game. The DApp also has an NFT marketplace. The users can buy and sell their NFTs inside the DApp. The users can also see the NFTs that are owned by other users even if they are not for sale.

Turtis

Working Demo of our DApp

The Application frontend is deployed to https://dodgingturtis.netlify.app/. Make sure you have Metamask installed in your browser and connect it to MATIC Mumbai Testnet using the Custom RPC option. Also, get some MATIC from the Faucet.

Turtis contract

Click here to view the Turtis contract on Polygonscan

The contract code has been verified and it is visible on mumbai.polygonscan.com

TurtisGameUserAuth contract

Click here to view the TurtisGameUserAuth contract on Polygonscan

The contract code has been verified and it is visible on mumbai.polygonscan.com

Built With

  • Ethereum - Ethereum is a decentralized platform that runs smart contracts
  • Chainlink - Chainlink's decentralized oracle network provides reliable, tamper-proof data for complex smart contracts
  • Polygon - Polygon is a protocol and a framework for building and connecting Ethereum-compatible blockchain networks and provides scalable solutions
  • Solidity - The most popular language for writing smart contracts
  • Phaser - An open source framework for building browser based games
  • ReactJS - A JavaScript library for building user interfaces
  • nft.storage - Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
  • IPFS - P2P network for storing and sharing files in a distributed file system
  • Filecoin - A decentralized storage network to store humanity's most important information
  • Truffle Framework - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier
  • Alchemy - To access a node which connects with Ethereum Blockchain on the Polygon Mumbai Testnet
  • Remix - Solidity IDE - To compile, test and deploy faster using Javascript VM
  • Visual Studio Code - Code Editor
  • Ganache - One Click Blockchain - Local blockchain for testing
  • Open Zeppelin - Open source Library of pre-built contracts
  • Metamask - Wallet Provider
  • Polygonscan - View and keep track of transactions happening around a smart contract as well as view its code, read and write stuff to it

The DApp User Interface

Turtis

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Please make sure you've already installed NPM & Yarn packages, Truffle and enabled MetaMask extension in your browser.

If you don't have yarn installed, run the following command:

npm install -g yarn

If you don't have Truffle installed, run the following command:

npm install -g truffle

Please make sure that the Metamask wallet is connected to the MATIC Mumbai Testnet and has some MATIC tokens.

Installing

A step by step guide to locally run the DApp

git clone https://github.com/Hardikag17/NFT-Game
  • Install all the required packages using the following command
yarn
  • Create a .env file and store the following contents in it and include API keys:
POLYGONSCAN_API_KEY="<Polygon API Key>"
MNEMONIC="<Enter your metamask seed phrase here>"
POLYGON_MUMBAI_RPC_URL="https://polygon-mumbai.g.alchemy.com/v2/<Alchemy API Key>"
  • To launch the DApp, use the following command:
yarn start

Libraries/services used

  • @truffle/hdwallet-provider - Used to create a provider using Seed phrase(Mnemonic) and Alchemy RPC URL to connect to the Blockchain
  • web3 - To interact with the deployed smart contract on Polygon Mumbai Testnet
  • @chainlink/contracts - To inherit ChainlinkClient contract to call an API using the decentralized Chainlink Oracles
  • @openzeppelin/contracts - To inherit the ERC721 based contracts
  • phaser - To build the game
  • react - For creating the fronted DApp
  • @ion-phaser/react - React specific wrapper for ion-phaser component
  • truffle-plugin-verify - To verify the smart contract code on Polygonscan using its API
  • dotenv - For managing data in .env files
  • solc - For compiling solidity contracts
  • ganache-cli - For running a local blockchain mostly used for testing purposes
  • mocha & chai - To test the smart contracts written in solidity
  • solhint - To lint solidity files
  • prettier & prettier-plugin-solidity - To format the code

Some versions of Frameworks and Libraries used in this project are

  • Truffle version - 5.3.14
  • Solidity version - 0.6.6
  • Node JS version - 14.16.1
  • @truffle/hdwallet-provider version - 1.4.1
  • web3 version - 1.4.0

Developers

Contributors

License

Licensed under MIT License : https://opensource.org/licenses/MIT