/challenge-0-simple-nft

Scaffold-Eth ๐Ÿ— Challenges repository

Primary LanguageCSSMIT LicenseMIT

๐Ÿ— scaffold-eth | ๐Ÿฐ BuidlGuidl

๐Ÿšฉ Challenge 0: ๐ŸŽŸ Simple NFT Example ๐Ÿค“

๐ŸŽซ Create a simple NFT to learn basics of ๐Ÿ— scaffold-eth. You'll use ๐Ÿ‘ทโ€โ™€๏ธ HardHat to compile and deploy smart contracts. Then, you'll use a template React app full of important Ethereum components and hooks. Finally, you'll deploy an NFT to a public network to share with friends! ๐Ÿš€

๐ŸŒŸ The final deliverable is an app that lets users purchase and transfer NFTs. Deploy your contracts to a testnet then build and upload your app to a public web server. Submit the url on SpeedRunEthereum.com!

๐Ÿ’ฌ Meet other builders working on this challenge and get help in the Challenge 0 telegram!!!


Checkpoint 0: ๐Ÿ“ฆ Install ๐Ÿ“š

Want a fresh cloud environment? Click this to open a gitpod workspace, then skip to Checkpoint 1 after the tasks are complete.

Open in Gitpod

Required:

  • Git
  • Node (๐Ÿงจ Use Node v16 or a previous version as v17 may cause errors ๐Ÿงจ)
  • Yarn

(โš ๏ธ Don't install the linux package yarn make sure you install yarn with npm i -g yarn or even sudo npm i -g yarn!)

git clone https://github.com/scaffold-eth/scaffold-eth-challenges.git challenge-0-simple-nft
cd challenge-0-simple-nft
git checkout challenge-0-simple-nft
yarn install
yarn chain

in a second terminal window, start your ๐Ÿ“ฑ frontend:

cd challenge-0-simple-nft
yarn start

in a third terminal window, ๐Ÿ›ฐ deploy your contract:

cd challenge-0-simple-nft
yarn deploy 

You can yarn deploy --reset to deploy a new contract any time.

๐Ÿ“ฑ Open http://localhost:3000 to see the app


Checkpoint 1: โ›ฝ๏ธ Gas & Wallets ๐Ÿ‘›

โ›ฝ๏ธ You'll need to get some funds from the faucet for gas.

image

๐ŸฆŠ At first, please don't connect MetaMask. If you already connected, please click logout:

image

๐Ÿ”ฅ We'll use burner wallets on localhost...

๐Ÿ‘› Explore how burner wallets work in ๐Ÿ— scaffold-eth by opening a new incognito window and navigate it to http://localhost:3000. You'll notice it has a new wallet address in the top right. Copy the incognito browsers' address and send localhost test funds to it from your first browser:

image

๐Ÿ‘จ๐Ÿปโ€๐Ÿš’ When you close the incognito window, the account is gone forever. Burner wallets are great for local development but you'll move to more permanent wallets when you interact with public networks.


Checkpoint 2: ๐Ÿ–จ Minting

โœ๏ธ Mint some NFTs! Click the MINT NFT button in the YourCollectables tab.

MintNFT

๐Ÿ‘€ You should see your collectibles start to show up:

nft3

๐Ÿ‘› Open an incognito window and navigate to http://localhost:3000

๐ŸŽŸ Transfer an NFT to the incognito window address using the UI:

nft5

๐Ÿ‘› Try to mint an NFT from the incognito window.

Can you mint an NFT with no funds in this address? You might need to grab funds from the faucet to pay the gas!

๐Ÿ•ต๐Ÿปโ€โ™‚๏ธ Inspect the Debug Contracts tab to figure out what address is the owner of YourCollectible?

๐Ÿ” You can also check out your smart contract YourCollectible.sol in packages/hardhat/contracts.

๐Ÿ’ผ Take a quick look at your deploy script 00_deploy_your_contract.js in packages/hardhat/deploy.

๐Ÿ“ If you want to make frontend edits, open App.jsx in packages/react-app/src.


Checkpoint 3: ๐Ÿ’พ Deploy it! ๐Ÿ›ฐ

๐Ÿ›ฐ Ready to deploy to a public testnet?!?

Change the defaultNetwork in packages/hardhat/hardhat.config.js to rinkeby

networkSelect

๐Ÿ” Generate a deployer address with yarn run generate

nft7

๐Ÿ‘› View your deployer address using yarn account

nft8

โ›ฝ๏ธ Use a faucet like faucet.paradigm.xyz or rinkebyfaucet.com to fund your deployer address.

โš”๏ธ Side Quest: Keep a ๐Ÿง‘โ€๐ŸŽค punkwallet.io on your phone's home screen and keep it loaded with testnet eth. ๐Ÿง™โ€โ™‚๏ธ You'll look like a wizard when you can fund your deployer address from your phone in seconds.

๐Ÿš€ Deploy your NFT smart contract:

yarn deploy

๐Ÿ’ฌ Hint: You can set the defaultNetwork in hardhat.config.js to Rinkeby OR you can yarn deploy --network rinkeby.


Checkpoint 4: ๐Ÿšข Ship it! ๐Ÿš

โœ๏ธ Edit your frontend App.jsx in packages/react-app/src to change the targetNetwork to NETWORKS.rinkeby:

image

You should see the correct network in the frontend (http://localhost:3000):

nft10

๐ŸฆŠ At this moment, you will need to connect the dapp to a browser wallet where you have some ether available to mint tokens. Again, you can use a faucet like [faucet.paradigm.xyz]. Keep in mind that the address you generated in the previous step to deploy the contract will likely be different from the one you have configured in your wallet.

๐ŸŽซ Ready to mint a batch of NFTs for reals? Use the MINT NFT button.

MintNFT2

๐Ÿ“ฆ Build your frontend:

yarn build

๐Ÿ’ฝ Upload your app to surge:

yarn surge

(You could also yarn s3 or maybe even yarn ipfs?)

๐Ÿ˜ฌ Windows users beware! You may have to change the surge code in packages/react-app/package.json to just "surge": "surge ./build",

โš™ If you get a permissions error yarn surge again until you get a unique URL, or customize it in the command line.

โš ๏ธ Run the automated testing function to make sure your app passes

yarn test

testOutput


Checkpoint 5: ๐Ÿ“œ Contract Verification

Update the api-key in packages/hardhat/package.json file. You can get your key here.

Screen Shot 2021-11-30 at 10 21 01 AM

Now you are ready to run the yarn verify --network your_network command to verify your contracts on etherscan ๐Ÿ›ฐ


Checkpoint 6: ๐Ÿ’ช Flex!

๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘จ Share your public url with a friend and ask them for their address to send them a collectible :)

nft15


โš”๏ธ Side Quests

๐ŸŸ Open Sea

Add your contract to OpenSea

  1. hover over your profile photo in the top right and navigate to Collections or go to https://opensea.io/collections my_collections
  2. click the vertical elipsis and select Import an existing smart contract import_contract
  3. select Live on a testnet live_on_testnet
  4. be sure you're on the same network you deployed to and enter your contract address! contract_address

(It can take a while before they show up, but here is an example:) https://testnets.opensea.io/assets/0xc2839329166d3d004aaedb94dde4173651babccf/1

๐Ÿ”ถ Infura

You will need to get a key from infura.io and paste it into constants.js in packages/react-app/src:

nft13


๐Ÿƒ Head to your next challenge here.

๐Ÿ’ฌ Meet other builders working on this challenge in the Challenge 0 telegram channel!!!

๐Ÿ‘‰ Problems, questions, comments on the stack? Post them to the ๐Ÿ— scaffold-eth developers chat