andy3520 / sre-simple-nft

https://andy-sre-c0.surge.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ— 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 and 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 (🧨 Currently use Node v16 as v17 & v18 are unstable 🧨)
  • Yarn

(⚠️ Don't install the linux package yarn make sure you install yarn with npm i -g yarn)

git clone https://github.com/scaffold-eth/scaffold-eth-typescript-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 deploy

in a third terminal window, πŸ›° deploy your contract:

cd challenge-0-simple-nft
yarn start

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 YourCollectibles tab.

πŸ‘€ 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-ts/contracts.

πŸ’Ό Take a quick look at your deploy script 00_deploy_your_collectible.ts in packages/hardhat-ts/deploy.

πŸ“ If you want to make frontend edits, open YourCollectible.tsx in packages/vite-app-ts/src/app/routes/your-collectibles.


Checkpoint 3: πŸ’Ύ Deploy it! πŸ›°

πŸ›° Ready to deploy to a public testnet?!?

Change the defaultNetwork in packages/hardhat-ts/hardhat.config.ts to georli

πŸ” Generate a deployer address with yarn generate

nft7

πŸ‘› View your deployer address using yarn account

nft8

⛽️ Use a faucet like faucet.paradigm.xyz 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.ts to goerli OR you can yarn deploy --network goerli.


Checkpoint 4: 🚒 Ship it! 🚁

✏️ Edit the TARGET_NETWORK_INFO in providersConfig.ts (in packages/vite-app-ts/src/config) to be the public network where you deployed your smart contract.

image

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

nft10

🎫 Ready to mint a batch of NFTs for reals? Use the MINT NFT button.

nft11

πŸ“¦ Build your frontend:

yarn build

πŸ’½ Upload your app to surge:

yarn surge

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

⚠️ 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-ts/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 ( create -> submit NFTs -> "or add an existing contract")

(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.ts in packages/vite-app-ts/src/models/constants:

nft13


πŸƒ Head to your next challenge here.

πŸ’¬ Problems, questions, comments on the stack? Post them to the πŸ— scaffold-eth developers chat

About

https://andy-sre-c0.surge.sh/

License:MIT License


Languages

Language:TypeScript 84.6%Language:JavaScript 7.3%Language:Shell 4.5%Language:Dockerfile 1.1%Language:Solidity 0.8%Language:HTML 0.8%Language:CSS 0.5%Language:Less 0.2%