1. NFT Collection
  2. Each NFT to have a "rarity"
  3. People pay to mint random dogs

Boilerplate: https://github.com/smartcontractkit/full-blockchain-solidity-course-js#lesson-9-hardhat-smart-contract-lottery




Flow:

yarn add --dev @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @nomiclabs/hardhat-etherscan @nomiclabs/hardhat-waffle chai ethereum-waffle hardhat hardhat-contract-sizer hardhat-deploy hardhat-gas-reporter prettier prettier-plugin-solidity solhint solidity-coverage dotenv

yarn hardhat

create empty hardhat.config.js

update solidity version in hardhat.config.js (^0.8.7)

mkdir contracts

mkfile in /contracts: RandomIpfsNft.sol

yarn hardhat compile

npm install --save-dev @openzeppelin/contracts

https://docs.chain.link/ethereum/

https://docs.chain.link/docs/get-a-random-number/


Chainlink reference: requestRandomWords(), 'request a puppy'

Chainlink reference: fulfillRandomWords(), 'mint a puppy'

yarn add @chainlink/contracts

'gas lanes': 'how much gas is max for getting a random number', 'if gas if more than 500 gwei...', 'allows to be careful about gas prices at time of minting'




Troubleshooting:



err: hardhat@2.9.7: The engine "node" is incompatible with this module. Expected version "^12.0.0 || ^14.0.0 || ^16.0.0". Got "18.0.0"

solution: https://stackoverflow.com/questions/56617209/the-engine-node-is-incompatible-with-this-module

wisdom: yarn install --ignore-engines




err: You are using a version of Node.js that is not supported by Hardhat, and it may work incorrectly, or not work at all.

Please, make sure you are using a supported version of Node.js.

To learn more about which versions of Node.js are supported go to https://hardhat.org/nodejs-versions

solution: uninstall node (https://www.imymac.com/powermymac/uninstall-node-mac.html) and reinstall node lts (https://nodejs.org/en/)