Giter VIP home page Giter VIP logo

speedrun_challenge0_nft's Introduction

๐Ÿšฉ Challenge #0: ๐ŸŽŸ Simple NFT Example

readme-0

๐ŸŽซ Create a simple NFT to learn basics of ๐Ÿ— Scaffold-ETH 2. 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: ๐Ÿ“ฆ Environment ๐Ÿ“š

Before you begin, you need to install the following tools:

Then download the challenge to your computer and install dependencies by running:

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

in the same terminal, start your local network (a blockchain emulator in your computer):

yarn chain

in a second terminal window, ๐Ÿ›ฐ deploy your contract (locally):

cd challenge-0-simple-nft
yarn deploy

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

cd challenge-0-simple-nft
yarn start

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


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

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

gas&wallet

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

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

๐Ÿ‘› Explore how burner wallets work in ๐Ÿ— Scaffold-ETH 2 by opening a new incognito window and navigate to http://localhost:3000. You'll notice it has a new wallet address in the top right. Copy the incognito browser's address and send localhost test funds to it from your first browser (using the Faucet button in the bottom left):

icognito&webBrowser

๐Ÿ‘จ๐Ÿปโ€๐Ÿš’ 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 My NFTs tab.

image

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

image

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

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

image

๐Ÿ‘› 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 for 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 edit the frontend, navigate to packages/nextjs/pages and open the specific page you want to modify. For instance: myNFTs.tsx.


Checkpoint 3: ๐Ÿ’พ Deploy your contract! ๐Ÿ›ฐ

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

Change the defaultNetwork in packages/hardhat/hardhat.config.ts to sepolia.

chall-0-hardhat-config

๐Ÿ” Generate a deployer address with yarn generate. This creates a unique deployer address and saves the mnemonic locally.

This local account will deploy your contracts, allowing you to avoid entering a personal private key.

chall-0-yarn-generate

๐Ÿ‘ฉโ€๐Ÿš€ Use yarn account to view your deployer account balances.

chall-0-yarn-account

โ›ฝ๏ธ You will need to send ETH to your deployer address with your wallet, or get it from a public faucet of your chosen network.

Some popular faucets are https://sepoliafaucet.com/ and https://www.infura.io/faucet/sepolia

โš”๏ธ 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 with yarn deploy.

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


Checkpoint 4: ๐Ÿšข Ship your frontend! ๐Ÿš

โœ๏ธ Edit your frontend config in packages/nextjs/scaffold.config.ts to change the targetNetwork to chains.sepolia :

chall-0-scaffold-config

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

image

๐ŸฆŠ Since we have deployed to a public testnet, you will now need to connect using a wallet you own or use a burner wallet. By default ๐Ÿ”ฅ burner wallets are only available on hardhat . You can enable them on every chain by setting onlyLocalBurnerWallet: false in your frontend config (scaffold.config.ts in packages/nextjs/)

image

๐Ÿ’ฌ Hint: For faster loading of your transfer page, consider updating the fromBlock passed to useScaffoldEventHistory in packages/nextjs/pages/transfers.tsx to blocknumber - 10 at which your contract was deployed. Example: fromBlock: 3750241n (where n represents its a BigInt). To find this blocknumber, search your contract's address on Etherscan and find the Contract Creation transaction line.

๐Ÿš€ Deploy your NextJS App

yarn vercel

Follow the steps to deploy to Vercel. Once you log in (email, github, etc), the default options should work. It'll give you a public URL.

If you want to redeploy to the same production URL you can run yarn vercel --prod. If you omit the --prod flag it will deploy it to a preview/test URL.

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

yarn test

Configuration of Third-Party Services for Production-Grade Apps.

By default, ๐Ÿ— Scaffold-ETH 2 provides predefined API keys for popular services such as Alchemy and Etherscan. This allows you to begin developing and testing your applications more easily, avoiding the need to register for these services.
This is great to complete your SpeedRunEthereum.

For production-grade applications, it's recommended to obtain your own API keys (to prevent rate limiting issues). You can configure these at:

  • ๐Ÿ”ทALCHEMY_API_KEY variable in packages/hardhat/.env and packages/nextjs/.env.local. You can create API keys from the Alchemy dashboard.

  • ๐Ÿ“ƒETHERSCAN_API_KEY variable in packages/hardhat/.env with your generated API key. You can get your key here.

๐Ÿ’ฌ Hint: It's recommended to store env's for nextjs in Vercel/system env config for live apps and use .env.local for local testing.


Checkpoint 5: ๐Ÿ“œ Contract Verification

You can verify your smart contract on Etherscan by running (yarn verify --network network_name) :

yarn verify --network sepolia

It is okay if it says your contract is already verified. Copy the address of YourCollectable.sol and search it on sepolia Etherscan to find the correct URL you need to submit this challenge.

Checkpoint 6: ๐Ÿ’ช Flex!

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

gif

โš”๏ธ Side Quests

๐ŸŸ Open Sea

๐Ÿƒ Want to see your new NFTs on Opensea? Head to Testnets Opensea

๐ŸŽซ Make sure you have minted some NFTs on your Vercel page, then connect to Opensea using that same wallet.

image

You can see your collection of shiny new NFTs on a testnet!

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


๐Ÿƒ Head to your next challenge here.

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

speedrun_challenge0_nft's People

Contributors

carletex avatar technophile-04 avatar zakgriffith avatar pabl0cks avatar rin-st avatar mertcanciy avatar arunanksharan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.