📚 This tutorial is meant for developers that already understand the 🖍️ basics .
🧑🏫 If you would like a more gentle introduction for developers, watch our 15 video 🎥 Web2 to Web3 series.
🎫 Create a simple NFT:
👷♀️ You'll compile and deploy your first 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!
Before you begin, you need to install the following tools:
- Node (>= v18.17)
- Yarn (v1 or v2+)
- Git
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 local instance of a blockchain):
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.
⛽️ You'll need to get some funds from the faucet for gas.
🦊 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):
👨🏻🚒 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.
✏️ Mint some NFTs! Click the MINT NFT button in the
My NFTs
tab.
👀 You should see your NFTs start to show up:
👛 Open an incognito window and navigate to http://localhost:3000
🎟 Transfer an NFT to the incognito window address using the UI:
👛 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/app
and open the specific page you want to modify. For instance: /myNFTs/page.tsx
. For guidance on routing and configuring pages/layouts checkout the Next.js documentation.
🛰 Ready to deploy to a public testnet?!?
Change the defaultNetwork in
packages/hardhat/hardhat.config.ts
tosepolia
.
🔐 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.
👩🚀 Use yarn account
to view your deployer account balances.
⛽️ 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
inhardhat.config.ts
tosepolia
OR you canyarn deploy --network sepolia
.
✏️ Edit your frontend config in
packages/nextjs/scaffold.config.ts
to change thetargetNetwork
tochains.sepolia
:
You should see the correct network in the frontend (http://localhost:3000):
🦊 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 onhardhat
. You can enable them on every chain by settingonlyLocalBurnerWallet: false
in your frontend config (scaffold.config.ts
inpackages/nextjs/
)
💬 Hint: For faster loading of your transfer page, consider updating the
fromBlock
passed touseScaffoldEventHistory
inpackages/nextjs/app/transfers/page.tsx
toblocknumber - 10
at which your contract was deployed. Example:fromBlock: 3750241n
(wheren
represents its a BigInt). To find this blocknumber, search your contract's address on Etherscan and find theContract 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.
yarn test
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 inpackages/hardhat/.env
andpackages/nextjs/.env.local
. You can create API keys from the Alchemy dashboard. -
📃
ETHERSCAN_API_KEY
variable inpackages/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.
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.
👩❤️👨 Share your public url with a friend and ask them for their address to send them a collectible :)
🐃 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.
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