How to use ERC721 tokens

How to use ERC721 tokens

Let’s now talk about non-fungible assets (NFTs). NFTs are usually created from ERC-721 smart contracts. Non-fungible assets are non-fungible because they differ in value and properties. So units of a non-fungible asset cannot be valued as another unit of a different asset. They are unique, not comparable, and are represented by unique tokens. So these NFTs, these tokens, are cryptographically unique. They are nonfungible digital assets created on the blockchain in the form of a token. They are often referred to as NFTs or non-fungible tokens, and they live in smart contracts. So we have collectible items including avatars and profiles, pictures, and virtual lands in these metaverse worlds like Sandbox, and SomniumSpace.

Why are they so special?

If we take metaverse lands, these are represented by NFT, so we can really own them. Also, we have video game items one can buy and own; for example, Star Atlas is a game where you can buy spaceships, which are represented by NFTs. also have digital art and physical art, which are totally disrupting the art world, and media and music too. It’s a blast after the 2020 Dogecoin meme was sold as an NFT. NBA Sports also sold NBA Top Shots Moment Games as an NFT. So the point is that real-world assets can be tokenized as long as they are legally recognized, and domain names like ENS (the Ethereum Name Service) are essentially ERC-721 tokens. NFT is also unlocking the potential of Web 3.0, the metaverse, and opening doors to a totally new world where digital artists and traditional artists can own and sell things, have royalties, and much more.

ERC-20 Vs ERC-1155 Vs ERC -721 tokens

There are other tokens, like ERC20, which is usually used for normal fungible tokens; ERC 1155, which is kind of a mix between both, and ERC 721 for nonfungible tokens. Fungible tokens can represent any fungible asset, and tokens are exactly the same from one to another. So usually, they use standard ERC-721 tokens.

Tokens are not really cryptocurrencies. Digital assets like Bitcoin, Ethereum, Dogecoin, or tokens are also fungible assets. So in this case, we have the Sandbox token, Chainlink, and Shiba. Axie Infinity Token (AXS), USTC Coin, FTX Token, Tether, or USDT, and Uniswap, etc. So there are many fungible tokens. So all these tokens that we see here are ERC-20 tokens; they are fungible tokens, but there are literally thousands of them, and we can also create our own tokens. They have all the same characteristics. And for each one of these projects that we see here, there were a number of tokens that were issued.

The Ethereum address and token ID are required to locate the erc721 token. The token id is a unique integer that can be identified inside the Erc 721 contract. This value is directly tied to their variety, which is made possible by an immutable blockchain and the contract made by blockchain too.

As we discussed in blockchain, which allows for the creation of smart contracts, we have the Ethereum blockchain, Binance Smart Chain, Polygon, Tron, EOS, and many others. So this is the protocol everyone has to follow, and on top of it, the ERC-20 tokens are created to fuel the economy. So we have completely new economies such as AXS and Sandbox, which are typically issued for fundraising; the team sells these tokens, and fundraising can also incentivize users to use them. 


Interplanetary File System, also known as IPFS, has distributed cloud storage; generally, we use cloud providers that are centralized, such as AWS (Amazon Web Service), Microsoft Azure, and Google. So anyone can have a node on this system, and you can also contribute to the nodes. For every image you upload to IPFS, the hash of that image will be generated, which is a content identifier.

These tokens are also used in DAOs, which are known as “decentralized autonomous organizations.” It basically resembles the rules of a company governed by a smart contract on the blockchain. So these are governed by corporate laws and regulations, which means coding in smart contracts. DAOs typically have a token that is used for governance voting and can also be viewed as a form of ownership in the company. So the token holders can make proposals to update the DAO, and each token in the organization represents a vote. People need to be able to spend the token, creating supply and demand for the token.

But if you build a token in such a way that this token is going to distribute dividends, then we have the ERC721 layer, and in the metaverse, we have tokens that represent lands or other NFTs that represent something like clothes inside the metaverse, new avatars, and a pair of shoes. Adidas also launched a few NFTs in 2021 and entered a big virtual market. People also create NFTS collections of 1,000, 100,000, and more items. So the assets are stored in decentralized storage. So we host or store these images on platforms such as IPFS and Filecoin. So the NFT images are not on the blockchain; these will be in IPFS and Filecoin, and the website will use some cloud provider. Ethereum is completing a big upgrade called “The Merge,” in which, in simple terms, it’s going to merge a consensus layer, a proof of stake consensus layer, with the execution layer of the blockchain infrastructure layer.

Set up the Goerli Testnet

To create an NFT or a token on testnets before moving to the mainnet, we need ether to pay testnet fees. So we will get some test ethers from the Goerli testnet. Go to the mining faucet (the link is here), and then open your Metamask wallet and change the network to the Goerli Test Network, then copy and paste the address there. The only requirement is that you create an Alchemy account, which is a platform that regulates blockchain applications and provides APIs to assist developers.

Well, after a few seconds, you will get it, depending on your computer, because it uses the hash rate of your CPU. They do it to avoid people spamming tonnes of people trying to get free ETH. There are other testnets like Ropsten, Kovan, and Rinkeby that were stopped after the merge upgrade. There are only the Goerli and Sepolia testnets. It seems to be pretty reliable, and it seems that you can also use the faucets to get some free test ETH.


We will deploy the ERC 721 smart contract to generate NFTs from OpenZappelin’s wizard. You can mint NFTs, and you can create token IDs within different token IDs, within the same smart contract. In ERC 721, we can create unique tokens. When we generate a lot of NFTs, we can see that each token ID will have different metadata pointing to a different image.

Now, when we open the website, we create a collection of Crypto_Monkeys by selecting ERC 721, which has the symbol name “monkey”. Also put the URL for the metadata, which contains the image that is pointing to the NFTs. We will also click on Mintable and the auto-increment IDs so that our NFTS have their own unique ID. Make sure that you are listed as the owner under the access control section. We can see the different mintable functions. URI storage will update the price for individual token IDs.

Now go to Solidity Remix and create a workspace. Under that, create a file called Monkey_nft.sol. Inside the file, just copy the code and paste it there, then compile it. Now we are going to deploy this smart contract. Click on “compile.” Now we will deploy this smart contract. Then choose the environment as “Injected Provider Metamask,” and it’s going to prompt the meta mask and copy the address of our test net. Then confirm it by clicking “OK.” Copy and paste your address, then click SafeMint to set the NFT. Then you’ll get something like this: 

Then click on the “deploy” button, and then you need to confirm the transaction; it shows something like this:

Confirm it

Now that our smart contract has been successfully created, we will mint NFT to use it, which requires us to click on the SafeMint button, copy our address, paste it there, click the button, and confirm it again, as shown below. 

Basically, we are going to create NFT number zero for ourselves. So now we have done it 2-3 times so that we can have different NFTs to show. By entering the ID, we can also determine who owns a specific nft. You can also select functions such as “safe wallet transfer,” “approve to,” “safe transfer,” and many more. 

Let’s check our account on OpenSea to see how many NFT’s we have. When you open the transaction’s metamask extension, you will see 

Click on View on the block explorer

There, we are directed to the Goerli scan, where we can see our history, address, and ERC-721 tokens. In ERC721 Token Txns, we can see our nfts having ids of 0, 1, and 2. We’ve done it three times now, so we can see it this way: 


We can follow the same steps in the Ethereum Mainnet test network, but keep in mind that once code is written, it cannot be changed; there is no way to undo it. Everything in the blockchain space has a cost, so proceed with caution. Web-3 developers’ demand is also increasing. Follow the Twitter space and join Discord too, career opportunities are increasing in the blockchain network. NFT created a completely new world in which digital and traditional artists could own and sell items, receive royalties, and much more.

Sharing is caring

Did you like what Nithin Reddy wrote? Thank them for their work by sharing it on social media.


No comments so far