Reader small image

You're reading from  The Essential Guide to Web3

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781801813471
Edition1st Edition
Concepts
Right arrow
Author (1)
Vijay Krishnan
Vijay Krishnan
author image
Vijay Krishnan

Vijay Krishnan, an experienced expert in blockchain and Web3, holds the position of head of SysOps for Linea, a Layer 2 blockchain at Consensys. With a rich background in blockchain, he's guided Fortune 100 companies from ideation to product build. With over 50 projects and 300+ use cases to his credit, Vijay has left an indelible mark on the industry. Prior to Consensys, he pioneered the AWS Partner Blockchain ecosystem and led IBM North America's Blockchain Practice. With two decades on Wall Street, he possesses deep financial and tech insights. Vijay, a leader and subject matter expert, empowers clients in DeFi, NFTs, gaming, and the metaverse. Beyond work, he's a mentor, speaker, author, and organic farmer. His knowledge and innovation continue to shape the blockchain and Web3 landscape.
Read more about Vijay Krishnan

Right arrow

Creating Your First Non-Fungible Token

In this chapter, you’ll mint your first non-fungible token (NFT), create an ERC721 smart contract, deploy it, and then mint the NFT. You’ll also use IPFS, a decentralized filesystem for building the next generation of the internet. You will also learn how to use Etherscan and one of the Ethereum explorers. This is a short chapter but a very important one as you will create your first NFT and experience a new digital economy out there.

In this chapter, we’re going to cover the following main topics:

  • Deploying your ERC-721 smart contract to Ethereum TestNet
  • Minting your first NFTs
  • Adding NFTs to your MetaMask wallet

Technical requirements

Before you begin ERC721 token creation, it is crucial to ensure that you have the necessary technical prerequisites in place. If you completed the hands-on work provided in Chapter 8, you have these set up already. However, I recommend running through the setup once more to ensure you have a valuable experience.

Here are the essential technical requirements:

  • Operating system (OS): You can choose your preferred OS; macOS is used in the examples here, but they can be adapted to your OS of choice.
  • GitHub command-line interface (CLI): Ensure you have the GitHub CLI installed and have access to GitHub. This is vital for version control and collaborative development.
  • Visual Studio Code (VS Code): Install VS Code, a popular code editor that streamlines smart contract development.
  • Node.js: Make sure Node.js is installed; it is a runtime environment necessary for running JavaScript-based applications. A better approach would be to use Node Version...

Launching an NFT project

Let’s consider a use case where we want to launch an NFT project with a collection of 10,000 images with a theme of saving the planet and spreading awareness of global warming. Here are some of the main steps you may want to consider:

  1. Create your vision and strategy: Define your mission statement, goals, and strategy for your NFT project. Consider what you want to achieve and what steps you need to take to get there.
  2. Create your artwork: The artwork will be the core of your NFT project. Make sure that you create quality images that align with your vision, and the concept of saving the planet and spreading awareness of global warming. Ensure that you create an image for each of the 10,000 NFTs that you plan to sell.
  3. Choose the NFT platform: Choose a platform to mint your NFTs, such as OpenSea, Rarible, or Nifty Gateway, and create an account.
  4. Mint your NFTs: Mint your NFTs using the images you have created. You will need to upload...

Deploying your ERC-721 smart contract to Ethereum TestNet

The Git project has already been unboxed for your convenience, which means it’s been prepared for you to start compiling and testing smart contracts. Follow these steps to successfully compile and deploy the smart contract onto the Hardhat blockchain:

  1. Launch VS Code on your computer. Navigate to the project folder that contains the unboxed Hardhat project. The following figure provides an example of how the project folder should look:
Figure 12.3 – VS Code with the Pet Store project open

Figure 12.3 – VS Code with the Pet Store project open

  1. Now that you are in the project folder within VS Code, you can proceed to compile and deploy the smart contracts to the Hardhat local blockchain. This process will involve using the Hardhat commands and interacting with the blockchain to simulate the deployment.

    The project folder in VS Code provides you with the environment to manage and interact with your smart contracts effectively...

Minting your NFTs

With that, we have come to the exciting part of this exercise, where our goal is to mint some cool pet NFTs and experience the process from end to end. Let’s jump right into it.

The following steps could be automated and programmed for a better experience, but we are going to do this manually so that you can learn what exactly is happening here. We are going to upload the pet pictures in the images folder into Pinata and capture all the URIs that will be used in the mint-pet-nfts.js script later:

  1. Log in to your Pinata account. Please make sure you have the necessary API keys, as mentioned in the Technical requirements section. The project folder contains an images folder with 24 images in it. These are pairs and they have thumbnails. First, let’s load all the images into Pinata so that we can set the custom attributes. Use the Upload button or the drag-and-drop functionality to upload all the pet pictures:
Figure 12.12 – Pinata file upload

Figure...

Adding your NFTs to your MetaMask wallet

Launch the MetaMask wallet on a web browser or desktop application. Ensure that the wallet is connected to the Ethereum Sepolia TestNet.

Follow these steps to add the NFTs you minted in the previous section to your MetaMask wallet:

  1. In the MetaMask wallet, under the NFTs tab, select the Import NFT option:
Figure 12.20 – Importing NFTs into MetaMask

Figure 12.20 – Importing NFTs into MetaMask

  1. In the Address field, paste the contract address of the minted NFT smart contract:
Figure 12.21 – Adding an NFT contract and tokens to MetaMask

Figure 12.21 – Adding an NFT contract and tokens to MetaMask

  1. Enter the contract address and the token ID. Verify that these details match your NFT smart contract outputs from previous steps. Repeat this for all the tokens you minted:
Figure 12.22 – Minted NFTs displayed in MetaMask

Figure 12.22 – Minted NFTs displayed in MetaMask

Figure 12.22 shows the final and desired output for this exercise. Congratulations! You have successfully...

Summary

This chapter painted a vivid picture of an NFT project aimed at saving the planet and raising awareness of global warming. You learned about the importance of strategic planning, high-quality artwork creation, and selecting the right NFT platform to bring your vision to life.

Before diving into the technical aspects, you were reminded of essential technical prerequisites such as OSs, the GitHub CLI, VS Code, Node.js, Hardhat, and web browsers. You also discovered the significance of Pinata accounts for creating IPFS URIs.

With the stage set, you delved into configuring and setting up a development environment, including cloning the pre-coded project and understanding its structure. After, you deployed your ERC-721 smart contract on the Ethereum Sepolia TestNet, securing vital details such as Infura API keys and private keys.

This chapter continued with an exhilarating exploration of minting NFTs, where you manually uploaded pet pictures to Pinata, configured attributes...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Essential Guide to Web3
Published in: Nov 2023Publisher: PacktISBN-13: 9781801813471
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Vijay Krishnan

Vijay Krishnan, an experienced expert in blockchain and Web3, holds the position of head of SysOps for Linea, a Layer 2 blockchain at Consensys. With a rich background in blockchain, he's guided Fortune 100 companies from ideation to product build. With over 50 projects and 300+ use cases to his credit, Vijay has left an indelible mark on the industry. Prior to Consensys, he pioneered the AWS Partner Blockchain ecosystem and led IBM North America's Blockchain Practice. With two decades on Wall Street, he possesses deep financial and tech insights. Vijay, a leader and subject matter expert, empowers clients in DeFi, NFTs, gaming, and the metaverse. Beyond work, he's a mentor, speaker, author, and organic farmer. His knowledge and innovation continue to shape the blockchain and Web3 landscape.
Read more about Vijay Krishnan