Published on September 1, 2022
How to Mint NFTs from an Ethereum Contract
A guide to minting directly from a smart contract with your crypto wallet on Etherscan.
7 min read
Minting lies at the heart of the NFT ecosystem, allowing individuals to create tokens of value on the blockchain. It is the process of infusing a digital asset with value. Until Proof-of-Work mining, the mint process creates coins and tokens through the verification of data.
Whereas in a traditional economy, this task has been delegated to centralized authorities, the premise of the decentralized space relies on the fact that interested individuals can perform the minting process themselves. The minting of cryptocurrencies or ERC-20 tokens can be done through Proof-of-Stake methods, which is a process of verifying transactions on the blockchain.
However, the minting process for NFTs, or ERC-721 tokens, is its own matter that we will be covering today. First, an interested minting party must have a web3 wallet for the minted NFT and hold the correct amount of cryptocurrency to cover the costs of the mint itself. Once these conditions are met, an NFT can be minted through platforms such as OpenSea or through an NFT project's website or online portal.
Today, we're going to dive into what it takes to not only mint an NFT on the Ethereum blockchain, but to do it directly through the smart contract for the NFT itself. But what does that mean, and why is it worth learning a slightly more complex process?
Why Mint from a Smart Contract?
While marketplaces such as OpenSea and other NFT projects allow for minting through their websites — and these functions are getting easier and more intuitive all the time — there are downsides.
First, anytime you connect your wallet to a new website, you inherently expose it to new risks. NFT scammers can utilize insecure websites to gain access to even protected wallets and investors. The more connected your wallet, the less secure it ultimately could become in the long run.
That said, security is not even the primary downside. OpenSea and other NFT marketplaces are relatively reliable regarding security, so the real problem is those marketplaces' popularity. As NFT projects become more desirable, a massive influx of holders will descend on markets and websites when minting opens up. This traffic makes it more challenging to access high-demand NFTs, and can even lead to website crashes during launches of particularly hyped projects.
That's where smart contracts come in. Smart contracts are always the framework beneath the mint process of an NFT. Essentially, smart contracts are programs that are the mechanisms for conducting transactions on the blockchain. So, even when utilizing a marketplace or website to mint, the underlying smart contracts do the work.
Increasingly, it is becoming possible to mint directly through a smart contract. This avoids the bottleneck of minting through a market or site, allowing buyers to mint NFTs faster, more efficiently, and without the unnecessary concern of connecting a valuable wallet to many different sites with potential security flaws.
That said, it is not the most intuitive process. That's why we're here to help, with a guide about how to mint NFTs directly through smart contracts on the Ethereum blockchain. While it might be daunting at first glance, the right tools are all easily available. Your journey to minting from a smart contract begins with Etherscan.
What is Etherscan?
Etherscan is one of the most important tools for any user or holder on the Ethereum blockchain. This search engine catalogs all transactions on Ethereum, allowing users a comprehensive and transparent database for research and purchases.
Not only are the transactions listed, but so are details such as whether it was successful or not. It's free to use and doesn't require an account. Using the hash key of a transaction, all of this is viewable to anyone.
Etherscan is also a portal for directly accessing and writing smart contracts for NFT mints.
A step-by-step guide to minting from contract on Etherscan
While it seems more complex on the surface, especially when markets and project websites make it simpler to mint through streamlined UI, there's an easy way to frame the mint process through smart contracts. Let's break it down into five primary stages for this tutorial.
Identify the Proper Smart Contract Address
All NFT projects provide a contract address for minting; you just have to find it. Usually, the best place to look will be on the project's hub, be it a website or Discord. However, if the NFT already exists on the open market, these details can also be found on OpenSea.
Simply navigate to the NFT's page, and click Details. Within, you can find the Contract address and other information on the token, including its metadata, token ID, and token standard (with NFTs usually falling into the ERC-721 token standard).
But back to the contract address – see that very long chain of numbers and letters? That's the one. Copy that down. Now it's time to head to Etherscan.
Find Smart Contract Through Etherscan
Head to Etherscan.io and input that contract address into the search function. If the contract address is correct, you'll end up on the Contract Page. Find the Contract tab. After clicking that, if you see the sub-menus for Code, Read Contract, and Write Contract — you're in the right place.
Connect Your Desired Wallet
Once you click Write Contract, you'll see more information on the NFT smart contract appear, along with the option to Connect to Web3. This function connects to the web3 wallet of your choice, such asMetaMask. Make sure you know which wallet you want to use because transferring between wallets incurs gas fees — no need to pay those more than once! With your MetaMask or favored wallet now connected, you're almost at the finish line. However, this might be unavoidable if you use a hot wallet to mint.
Set Mint Price & Mint Number
With the Write Contract sub-menu still expanded, you will now see a numbered list of options. The label you want to seek out will most likely be 'mint' or 'claim.' Expand this section to find the mint price and mint number boxes. Enter the correct minting price in the first field, and the number of NFTs that you want to mint in the second field. The mint price should be known to you from the project's website, Discord, or main hub.
Here's the less fun part — you also need to check on gas fees, which are the transaction fees on all blockchain exchanges. They are variable and constantly changing based on supply, demand, and other factors. Once again, Etherscan.io is your friend here. In the top left corner of the page, you should be able to find the current gas price for this NFT. Ask yourself if that price is a dealbreaker or not, then add it into your mint price category alongside the initial cost.
For big spenders, there is also always the option of paying a higher gas fee than the market standard to make your transaction a higher priority. This can help ensure your transaction on the blockchain is a high priority and completed quickly.
Lastly, input the mint number, or the amount of NFTs you want to mint from this smart contract. With all of that ready to go…
Mint Directly From Smart Contract
It's finally time! Below the mint price and mint amount categories, you'll see the Write button. Clicking that verifies the transaction by sending it to the Ethereum blockchain. Depending on gas fees, the transaction can occur quickly, or it may take a little while to process.
Did My Mint Go Through?
Good question. There is an extra step that is easy to take. Return to the contract address page on Etherscan.io to check the transaction status. Remember, all transaction history from the Ethereum blockchain will be registered here. There you will be able to see if the transaction succeeded, failed, or is still pending. That can provide peace of mind in high-stress minting scenarios!