Skip to content

Implementation of a basicNFT, a randomNFT (using Chainlink VRF) with metadata hosted on IPFS and a dynamicNFT whose metada is computed on chain and varies depending on ETH price (using Chainlink Price Feeds).

JMariadlcs/nfts-full-repo

Repository files navigation

NFTS FULL REPO 🌃🌟

This is a repo about NFTs. This repo is similar to the NFT-dynamic-fully-on-chain and NFT-IPFS-VRF repos but all together and much complete. Testing is done in this repo.

Altough this repo is a similar implementation of the other 2 mentioned repos, this one is more structurated, is constructed in such a way that can be deployed on different chains automatically and testing is done and pinata is used to host NFT Uris.

This is a workshop from Patrick Alpha's FFC couse.

The workshop followed to complete this repo is this one.

The repo that we are going to implement is like this one.


NFT Pug NFT Shiba NFT St.Bernard



NFT Happy NFT Frown


PROJECT

We are creating 3 contracts for different NFT implementations:

  1. Basic NFT ✅.
  2. Random IPFS NFT ✅.
    • Pros: Cheap.
    • Cons: Someone needs to pin our data.
  3. Dynamic SVG NFT ✅.
    • Pros: Data is on-chain.
    • Cons: Much more expensive.
    • Objetives: Mint an NFT based on the price of ETH
      • If ETHprice > someNumer: NFT1
      • if ETHprice < someNumber: NFT2

CREATE SIMILAR PROJECT FROM SCRATCH

  • Install yarn and start hardhat project:
yarn
yarn add --dev hardhat
yarn hardhat
  • Install ALL the dependencies:
yarn add --dev @nomiclabs/hardhat-waffle@^2.0.0 ethereum-waffle@^3.0.0 chai@^4.2.0 @nomiclabs/hardhat-ethers@^2.0.0 ethers@^5.0.0 @nomiclabs/hardhat-etherscan@^3.0.0 dotenv@^16.0.0 eslint@^7.29.0 eslint-config-prettier@^8.3.0 eslint-config-standard@^16.0.3 eslint-plugin-import@^2.23.4 eslint-plugin-node@^11.1.0 eslint-plugin-prettier@^3.4.0 eslint-plugin-promise@^5.1.0 hardhat-gas-reporter@^1.0.4 prettier@^2.3.2 prettier-plugin-solidity@^1.0.0-beta.13 solhint@^3.3.6 solidity-coverage@^0.7.16 @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers @chainlink/contracts hardhat-deploy hardhat-shorthand @aave/protocol-v2
  • Install OpenZeppelin dependencies (contracts):
yarn add --dev @openzeppelin/contracts
  • Install Base64 dependencies (to encode SVGs):
yarn add --dev base64-sol

UPLOAD FILES TO PINATA

yarn add --dev @pinata/sdk
yarn add --dev path
yarn hardhat deploy --tags randomipfs

HOW TO COMPILE

yarn hardhat compile

or

npx hardhat compile

HOW TOT DEPLOY

If you want to use Hardhat shorthand:

yarn global add hardhat-shorthand
  • Deploy to local network (Harhat by default):
hh compile
hh deploy
  • Deploy to a TESTNET (Rinkeby): You can not deploy all scripts at the same time because you can deploy mint.js script without firtly add randomNFT to ConsumerBase.

To deploy every script expect mint.js:

yarn hardhat deploy --network rinkeby --tags main

HOW TO TEST

Two types of tests are created for this project:

  1. "Unit tests" inside unit: used to test functions separately

To execute tests unit tests (on development chain):

yarn hardhat test

and to see test coverage:

yarn hardhat coverage

REMINDERS

NOTICE: most of the below mentioned dependencies are already installed, just check it and include the corresponding requires inside hardhat.config.js.

  • If you want to execute solhint to search for potential Solidity errors Execute:
yarn solhint contracts/*.sol
yarn add --dev @nomiclabs/hardhat-etherscan

Then, include inside hardhat.config.js:

require("@nomiclabs/hardhat-etherscan");

Add ETHERSCAN_API_KEY inside .env file.

  • Use Hardhat Gas Reporter:
yarn add --dev hardhat-gas-reporter

Then, include inside hardhat.config.js:

require("hardhat-gas-reporter");
  • Use Solidity Coverage:
yarn add --dev solidity-coverage

Then, include inside hardhat.config.js:

require("solidity-coverage");

In order to execute it:

yarn hardhat coverage
  • Use Hardhat Waffle:
yarn add @nomiclabs/hardhat-waffle

Then, include inside hardhat.config.js:

require("@nomiclabs/hardhat-waffle");

RESOURCES

  1. BASIC NFT:
  1. RANDOM NFT:
  1. DYNAMIC SVG NFT:

About

Implementation of a basicNFT, a randomNFT (using Chainlink VRF) with metadata hosted on IPFS and a dynamicNFT whose metada is computed on chain and varies depending on ETH price (using Chainlink Price Feeds).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published