Site icon EASY2DIGITAL

Web3 NFTs – Build and List NFTs Using Python, Openzeppelin, Pinata

Token economy is a hot vocabulary in the business world. Two main types of tokens, which is fungible and non-fungible tokens. NFTs (non-fungible token) is a unique digital identifier that cannot be copied, substituted, or subdivided, that is recorded in a blockchain. It provides a public certificate of authenticity or proof of ownership. 

Assets, notably intangible assets can be evaluated continuously and publicly in an absolutely transparent and disruptive way, compared to traditional intangible asset valuation, although NFT ownership itself has no inherent legal meaning.

In this article, I would go through how to build your Web3 NFT collections using Python, Openzeppelin, and Pinata, which can be listed on Opensea markets.

Ingredients on Web3 NFT – Build NFTs Using Python, Openzeppelin, Solidity

Table of Contents

NFT Smart Contract

As well as a fungible token, we need to start by developing the smart contract code in NFT development. 

First thing first, we can make well use of existing modules out there, such as Openzeppelin, which can save some time to develop common functions. Please be sure to add the dependencies in the brownie-config.YAML as well. If you have any questions related to this, please refer to other articles in the Easy2Digital web3 collection.

// contracts/GameItem.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

As you can see ERC721, which is different from the fungible token ERC20, it’s the standard non-fungible token. Thus, under this module, we create a contract using ERC721.

contract SimpleCollection is ERC721 {

   uint256 public to encounte;

   constructor() public ERC721("LouisNFT", "LVnft") {

       tokenCounter = 0;

   }

   function createCollection(string memory tokenURI) public returns (uint256) {

       uint256 newTokenId = tokenCounter;

       _safeMint(msg.sender, newTokenId);

       _setTokenURI(newTokenId, tokenURI);

       tokenCounter = tokenCounter + 1;

       return newTokenId;

   }

}

Metadata

Metadata is a JSON file that allows applications like OpenSea to pull in rich data for digital assets and easily display them in-app. Here are the elements included in a basic metadata file as follows:

Storing data on the blockchain can be very expensive, except for those script files. Nevertheless, images, videos, and audio which can be large sizes of material can be pricy stored on the blockchain.

So normally we can leverage using decentralized storage such as IPFS. IPFS or inter-planetary file system is a protocol, hypermedia, and file-sharing peer-to-peer network for storing and sharing data in a distributed file system.

There are two ways basically to upload your NFT materials to IPFS. One is to install a local IPFS environment to interact with the IPFS network. The other is to run through a 3rd party platform, such as Pinata.

Upload the NFT image and JSON file to Pinata for generating a token URI.

First thing first, the 1st step is to create a Pinata account and prepare the image you like to convert into NFTs.

Then, upload the image as the file onto Pinata and then you can get a CID key from this materials. The key would be used in a moment to create a JSON file.

Additionally, as the token URI is a JSON file, the next step is to add all information related to NFT in a JSON file. Here is a sample using VSC as follows:

Last but not least, once the JSON file is ready, please go back to Pinata and upload the JSON and generate the JSON file CID key. Here is the sample of the final token URI of the IPFS URL.

https://ipfs.io/ipfs/QmV8rPonNpVaKnH2ri826AWqJ5XxeKYdeJupjKch4kA1UK?filename=NFT1.json

Opeasea Account Integration

OpenSea is the world’s first and largest web3 marketplace for NFTs and crypto collectibles. Browse, create, buy, sell, and auction NFTs using OpenSea. For any NFTs, listing to a marketplace is very common no matter it’s for the purpose to sell or not. Notably, most companies leverage this to build brand awareness and assist to implement loyalty programs as well.

For this case, we can simulate the NFTs listing process by using opensea testnet. Creating an opeansea testnet account is totally free. In our case, we would use MetaMask to list NFTs. So please be sure to sign up the opensea test account connecting with the MetaMask testnetwork account as well.

For the opeansea testnext NFT URL, basically, it has two variables which are the cryptocurrency network and the 

For the opeasea listing URL, the structure has two variables and here is the sample

https://testnets.opensea.io/assets/goerli/0x8eeb73f75e6d80a6a21302d1ec36d0ead0ceb295/0

We’ll use this in a moment on the Python deployment scripts.

Python Deployment Script

Apart from importing the brownie and assistscript modules as well as building fungible token, NFT deployment needs two variables. They are the sample_collection_URI and OPEASEA_URL

sample_collection_URI = "https://ipfs.io/ipfs/QmV8rPonNpVaKnH2ri826AWqJ5XxeKYdeJupjKch4kA1UK?filename=NFT1.json"

OPENSEA_URL = "https://testnets.opensea.io/assets/{}/{}"

Then in the main function, we need to use the createcollection functions as created earlied in the NFT smart contract

def main():

   account = get_account()

   Simple_Collection = SimpleCollection.deploy({"from": account})

   tx = Simple_Collection.createCollection(

       sample_collection_URI, {"from": account})

   tx.wait(1)

Brownie-config, ENV, and assistScripts

As well as fungible token development, we need to add on these scripts. For more details, please refer to these articles

Use Infura and MetaMask in Python Scripts to Deploy Web3 Smart Contracts on a Real Ethereum BlockChain Network

Brownie FundMe Smart Contract Deployed on Ethereum Using Python & Web3

Once the scripts are ready, we can run the scripts on the specific network and the result here shows it’s done and the NFT has been listed on the marketplace.

Brownie run scripts/deploy_NFTCreate.py –network goerli

Full Scripts of Building NFTs Using Python, Openzeppelin, Pinata

If you are interested in Web3 NFTs – Build and List NFTs Using Python, Openzeppelin, Pinata, please subscribe to our newsletter by adding the message “Web3.0 tutorial 7”. We would send you the script immediately to your mailbox.

I hope you enjoy reading Web3 NFTs – Build and List NFTs Using Python, Openzeppelin, and Pinata. If you did, please support us by doing one of the things listed below, because it always helps out our channel.

FAQ:

Q1: What are Web3 NFTs?

A: Web3 NFTs are non-fungible tokens (NFTs) that are created and stored on a blockchain, typically the Ethereum blockchain. They are unique digital assets that can represent ownership of items such as art, music, videos, and even real estate.

Q2: What are the benefits of using Web3 NFTs?

A: Web3 NFTs offer several benefits over traditional NFTs, including increased security, transparency, and decentralization. They are also more easily verifiable and can be used to represent a wider range of assets.

Q3: How are Web3 NFTs created?

A: Web3 NFTs are created by uploading a digital file to a blockchain, typically the Ethereum blockchain. The file is then converted into a unique token that can be bought, sold, and traded.

Q4: Where can I buy and sell Web3 NFTs?

A: Web3 NFTs can be bought and sold on a variety of NFT marketplaces, such as OpenSea, Rarible, and SuperRare. These marketplaces allow users to create, buy, and sell NFTs using cryptocurrency.

Q5: What is the difference between Web3 NFTs and traditional NFTs?

A: Traditional NFTs are typically created and stored on a centralized platform, such as a company’s server. This means that they are subject to the same risks as any other centralized system, such as hacking and censorship. Web3 NFTs, on the other hand, are created and stored on a decentralized blockchain, which makes them more secure and resistant to censorship.

Q6: What are some of the most popular use cases for Web3 NFTs?

A: Some of the most popular use cases for Web3 NFTs include digital art, music, videos, and real estate. However, Web3 NFTs can be used to represent ownership of any type of digital asset, including documents, contracts, and even physical objects.

Q7: What are the future trends for Web3 NFTs?

A: The future of Web3 NFTs is bright. As the technology continues to develop, we can expect to see more innovative and creative use cases for Web3 NFTs. We can also expect to see the emergence of new platforms and marketplaces for buying and selling Web3 NFTs.

Q8: What are the challenges facing Web3 NFTs?

A: One of the biggest challenges facing Web3 NFTs is the high cost of gas fees. Gas fees are the fees that are paid to miners to process transactions on the blockchain. These fees can be prohibitively expensive, especially for small-scale artists and creators.

Q9: How can Web3 NFTs be used to improve the world?

A: Web3 NFTs can be used to improve the world in a number of ways. For example, they can be used to create a more secure and transparent voting system. They can also be used to track the provenance of goods and services, which can help to reduce fraud and corruption.

Q10: What are the risks associated with Web3 NFTs?

A: There are a number of risks associated with Web3 NFTs, including the risk of fraud, theft, and hacking. It is important to do your research and only invest in Web3 NFTs from reputable sources.

Exit mobile version