Website: https://crypto-kitties.netlify.app
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.
Contracts are written in Solidity
- 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.
- KittyCore is build in the following way
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.
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.
There is a limited amount of gen0 kitties available, defined by CREATION_LIMIT_GEN0
. Only the owner can mint new kitties (using createGen0Kitty
)
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 is simulated through using the timestamp of the mined block.
- 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
- Start up local blockchain (ganache or ganache-cli)
TIP: When using ganache-cli, useganache-cli -d
organache-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
- 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 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
- Have node and yarn installed
- Have a way to run a blockchain locally
- Have MetaMask installed
- Install dependencies
cd smart-contracts yarn install
cd client
- Make sure that a local blockhain is running ( via ganache).
- Update the contract JSONs in
src/assets/contracts
- Have all node_modules installed
- Start local development
yarn start
Have netlify-cli
installed
npm install netlify-cli -g