Giter VIP home page Giter VIP logo

crypto-kitties's Introduction

Cats

Netlify Status

Website: https://crypto-kitties.netlify.app

CryptoKitties

CryptoKitties is a ERC721 token, where you can buy, sell and breed your own kitties.

Part of Ivan on Tech Ivan on Tech Academy bootcamp.

Table of Contents

Ethereum

Contracts are written in Solidity

Smart contract structure

  • KittyCore forms the basic of all kitty interactions. It is split into mutliple contracts, inheriting from eachother to make life more easy.
    • KittyCore is build in the following way
      • KittyBase: All core logic and variables
      • KittyOwnership (inherits from KittyBase): All logic to make it ERC721 KittyBase
      • KittyBreeding (inherits from KittyBreeding): All logic to breed kitties
      • KittyMinting (inherits from KittyBreeding): All logic to make new gen0 kitties
      • KittyCore (inherits from KittyMinting): Final contract that is used to interact with everything
    • MarketPlace is not inheriting from KittyCore and is a standalone contract. It requires the address of KittyCore to interact with.

ERC721

The following standard allows for the implementation of a standard API for NFTs within smart contracts. This standard provides basic functionality to track and transfer NFTs.

A standard interface allows wallet/broker/auction applications to work with any NFT on Ethereum. We provide for simple ERC-721 smart contracts as well as contracts that track an arbitrarily large number of NFTs. Additional applications are discussed below.

ERC 165

ERC165’s solution is to define a standard for contracts to publish what interfaces they support, so that other contracts can follow the same standard to detect whether it supports certain interfaces, and only call the interface’s function if the interface is supported.

Gen0

There is a limited amount of gen0 kitties available, defined by CREATION_LIMIT_GEN0. Only the owner can mint new kitties (using createGen0Kitty)

DNA

Every kitty has unique DNA, comprised of a 16 digits. When breeding 2 kitties, the child will have a mixture between the dna of its mom and its dad. It also has a chance to mutate a gene randomly

Randomness

Randomness is simulated through using the timestamp of the mined block.

Instalation

  • Have node installed (v10 or later)
  • Have yarn installed npm install -g yarn (or npm)
  • Have truffle installed npm install -g truffle
  • Have ganache-cli or ganache installed
  • Install dependencies
    cd smart-contracts
    yarn install

Deploy locally

  • Start up local blockchain (ganache or ganache-cli)
    TIP: When using ganache-cli, use ganache-cli -d or ganache-cli --mnemonic 'myth like bonus scare over problem client lizard pioneer submit female collect' to always get the same account addresses.
  • Run truffle deploy The contracts should deploy on your locak blockchain

NOTE: make sure to copy build/KittyCore and build/MarketPlace to /client/src/assets/contracts

Deploy to test network

  • Make a file to store the mnemonic secret in touch .secret and add your secret.
  • Update the INFURA_PUBLIC_KEY in truffle-config
  • Run truffle deploy --network ropsten

NOTE: make sure to have Ether in your first account

NOTE: make sure to copy build/KittyCore and build/MarketPlace to /client/src/assets/contracts

Client

Client is made with React

  • bootstrapped with Create React App.
  • @web3-react in combination with ethers.js (ethersproject) to handle smart contract interactions.
  • Uses Material UI from UI components

Instalation

  • Have node and yarn installed
  • Have a way to run a blockchain locally
  • Have MetaMask installed
  • Install dependencies
    cd smart-contracts
    yarn install

Local development

  1. cd client
  2. Make sure that a local blockhain is running ( via ganache).
  3. Update the contract JSONs in src/assets/contracts
  4. Have all node_modules installed
  5. Start local development
yarn start

Deploy client

Have netlify-cli installed

npm install netlify-cli -g

Images

Preview Preview2

crypto-kitties's People

Contributors

ernow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.