๐Ÿธ
Chainlink ๐ŸŽฒ VRF ๐ŸŽซ NFT
Use VRF to get a ๐ŸŽฒ random "โš”๏ธ strength" for each NFT as it is minted...

Branch Info

Author: Austin Griffith Source code: https://github.com/scaffold-eth/scaffold-eth-examples/tree/chainlink-vrf-nft Intended audience: Beginners/Intermediate Topics: Scaffold-eth basics, NFTs, Chainlink

๐Ÿƒโ€โ™€๏ธ Quick Start

โ€‹โ€‹
โ€‹
โ€‹
required: Node plus Yarn and Gitโ€‹
1
git clone https://github.com/scaffold-eth/scaffold-eth-examples.git buyer-mints-nft
2
โ€‹
3
cd buyer-mints-nft
4
โ€‹
5
git checkout buyer-mints-nft
Copied!
1
yarn install
Copied!
1
yarn start
Copied!
in a second terminal window:
1
cd simple-nft-example
2
yarn chain
Copied!
โœ๏ธ Edit the artwork manifest artwork.js with all of your art, then upload it to IPFS:
in a third terminal window:
1
cd simple-nft-example
2
โ€‹
3
yarn upload
4
โ€‹
5
yarn deploy
Copied!
๐Ÿ“ฑ Open http://localhost:3000 to see the app
Your artwork from artwork.json (if uploaded and deployed correctly) should show a gallery of possible NFTS to mint:
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ’ฆ Use the faucet wallet icon in the bottom left of the frontend to give your address $1000 in testnet ETH.
๐ŸŽฒ This repo uses Chainlink's VRF on Rinkby.
First call getRandomNumber() from the debug contracts tab:
โ€‹โ€‹
โ€‹
โ€‹
Wait for the randomResult to get set:
โ€‹โ€‹
โ€‹
โ€‹
Finally, mint from the gallery tab and your NFT will have a tokenStrength:
โ€‹โ€‹
โ€‹
โ€‹
๐ŸŽซ Try to "Mint" an NFT:
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ‘› Open an incognito window and navigate to http://localhost:3000 (You'll notice it has a new wallet address).
โ›ฝ๏ธ Grab some gas for each account using the faucet:
โ€‹โ€‹
โ€‹
โ€‹
๐ŸŽŸ Send an NFT to the incognito window just to make sure it works.
๐Ÿ•ต๐Ÿปโ€โ™‚๏ธ Inspect the Debug Contracts tab to figure out what address is the owner of YourCollectible?
๐Ÿ’ผ Edit your deployment script deploy.js in packages/hardhat/scripts
๐Ÿ” Edit your smart contract YourCollectible.sol in packages/hardhat/contracts
๐Ÿ“ Edit your frontend App.jsx in packages/react-app/src
๐Ÿ”‘ Create wallet links to your app with yarn wallet and yarn fundedwallet
โฌ‡๏ธ Installing a new package to your frontend? You need to cd packages/react-app and then yarn add PACKAGE

๐Ÿ“ก Deploy NFT smart contract!

๐Ÿ›ฐ Ready to deploy to a testnet?
Change the defaultNetwork in packages/hardhat/hardhat.config.js
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ” Generate a deploy account with yarn generate
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ‘› View your deployer address using yarn account (You'll need to fund this account. Hint: use an instant wallet to fund your account via QR code)
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ“ Triple check your artwork.json file and run:
1
yarn upload
Copied!
๐Ÿ‘จโ€๐ŸŽค Deploy your NFT smart contract:
1
yarn deploy
Copied!
โœ๏ธ Edit your frontend App.jsx in packages/react-app/src to change the targetNetwork to wherever you deployed your contract:
โ€‹โ€‹
โ€‹
โ€‹
You should see the correct network in the frontend:
โ€‹โ€‹
โ€‹
โ€‹
An instant wallet running on xDAI insired by xdai.io.

โš”๏ธ Side Quests

๐ŸŸ Open Sea
Add your contract to OpenSea ( create -> submit NFTs -> "or add an existing contract" )
(It can take a while before they show up, but here is an example:)
๐Ÿ” Etherscan Contract Verification
run yarn flatten > flat.txt (You will need to clean up extra junk at the top and bottom of flat.txt. Sorry, rookie stuff here.)
copy the contents of flat.txt to the block explorer and select compiler v0.6.7 and Yes to Optimization (200 runs if anyone asks)
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ”ถ Infura
You will need to get a key from infura.io and paste it into constants.js in packages/react-app/src:
โ€‹โ€‹
โ€‹
โ€‹

๐Ÿ›ณ Ship the app!

โš™๏ธ build and upload your frontend and share the url with your friends...
1
# build it:
2
โ€‹
3
yarn build
4
โ€‹
5
# upload it:
6
โ€‹
7
yarn surge
8
โ€‹
9
Join the telegram [support chat ๐Ÿ’ฌ](https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA) to ask questions and find others building with ๐Ÿ— scaffold-eth!
10
โ€‹
11
yarn s3
12
โ€‹
13
===================================================== [โซ back to the top โซ](https://github.com/austintgriffith/scaffold-eth#-scaffold-eth)
14
โ€‹
15
yarn ipfs
Copied!
โ€‹โ€‹
โ€‹
โ€‹
๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘จ Share your public url with a friend and ask them to buy a collectible
โ€‹โ€‹
โ€‹
โ€‹