NFTs provide a way to create unique digital assets on the blockchain through the minting of tokens. To successfully mint an NFT, we must follow the ERC-721 standard.
ERC-721 is a free, open standard of interfaces that describes building non-fungible tokens on the Ethereum blockchain. Unlike ERC-20 tokens, which are fungible, NFTs are unique digital assets that can’t be duplicated. Think of NFTs as rare, one-of-a-kind collectables giving them the name.
In this tutorial, we’ll demonstrate how to mint an NFT from an existing smart contract on Etherscan.
We’ll explore a recent collection project, Expansion Punk, using Etherscan to search and locate the smart contract. Using the Etherscan interfaces provided to interact with the smart contract’s public functions, we’ll use the mint function to mint NFTs directly from Etherscan.
Before you start minting, keep in mind that minting a particular collection of NFTs will only work if the project isn’t yet sold out.
Step 1: Find smart contract address
Blockchain assets and activities are indexed on Etherscan using a unique ID address as well as smart contracts. To search for a smart contract on Etherscan, we need the unique ID or address of the smart contract.
We can find the smart contract address of an ERC-721 project by opening the Details section of the minted assets on OpenSea. Or, we can check the project’s Discord server or website for the smart contract address.
Once we have the address, we can visit Etherscan.io to search for the smart contract:
Step 2: Search Etherscan using the smart contract address
Once you’re on Etherscan’s website, copy and paste the address into the search component of the website, as shown above.
For this tutorial, we’ll use the Expansion Punk smart contract address,
0x0d0167a823c6619d430b1a96ad85b888bcf97c37, to search Etherscan for the smart contract.
This is the homepage of the smart contract address on Etherscan. It shows details regarding the balance, transactions, and more. We’re mostly interested in the Contract tab because this is where we’ll find the functions required to mint NFTs.
Step 3: Connect to a Web3 network using MetaMask
Navigate to the Contract tab by clicking the Contract link on the smart contract homepage. We’ll find within this section a button labeled Write Contract:
Clicking the Write Contract button will open up several options, including the various interfaces available within the smart contract that can be executed.
But before we start implementing any of the functions, we need to first connect to our MetaMask account using the Connect to Web3 button. This will prompt your MetaMask extension to open in your browser. If you have multiple accounts, do well to choose and connect your preferred account.
Step 4: Mint the NFT from the smart contract
Once we’ve connected our MetaMask account, we can start interacting with the smart contract interface.
In most smart contracts, the function we should look for to mint NFTs would be the mint function or the claim function. This name is unique to the project; you can distinguish the minting function with any preferred function name.
This project uses the mint function name to implement its minting function. Locate the mint function for the smart contract (it’s the fourth function). Expand it as shown below:
Expanding the mint section will expose the input field to provide the options you want to mint. The first input field provides us with the option of inserting the minting price (0.42 ETH, in this case) and the number (7) you would like to mint in the second input. Do check the minting options of the project to provide the desired information to the inputs.
Next, we click the Write button to send the transaction to the blockchain. In some cases, this process might take time to finalize the transaction. We can pay a higher gas fee to fast-track this process by adjusting the gas fee on our MetaMask wallet.
The above steps comprise the process for minting non-fungible tokens with a smart contract on Etherscan. But remember, the steps are not the same for every smart contract. You need to know the smart contract address before using it to mint NFTs because every smart contract is different.
Also, the blockchain is irreversible, so always double-check all transactions before confirming. A good use case for minting NFTs in this way is when a project’s website is down due to high traffic. This serves as a good alternative to minting NFTs with the smart contract on the project website.
LogRocket is like a DVR for web and mobile apps, recording everything that happens in your web app or site. Instead of guessing why problems happen, you can aggregate and report on key frontend performance metrics, replay user sessions along with application state, log network requests, and automatically surface all errors.
Modernize how you debug web and mobile apps — Start monitoring for free.