Mint an NFT and ERC-721 Smart Contract — Easy Step-by-step! PlatoBlockchain Data Intelligence. Vertical Search. Ai.

Mint an NFT and ERC-721 Smart Contract — Easy Step-by-step!

You will be very proud of yourself after minting your own NFT with a Smart Contract deployed by yourself! This is what you need to know to create an NFT Smart Contract and mint new NFTs with Ethereum Remix!

Henrique Centieiro

As you all know, I love to have feedback from my students to update my online courses.

Marlus, a student of mine from the NFT Course, asked the following question:

I’m very interested in code and deploy my own ERC-721 contract, do you plan to include something about that in the course?

Dear Marlus, your wishes are my duty!

In this article, we will follow these important steps (I assume that you have already Metamask installed):

  1. Get some test Ether

BEFORE moving forward with these steps, if you need to get familiar with the NFT concept and tools, you can also check the articles below:

Step-by-step NFT minting using IPFS (this article features Pinata and OpenSea)

What are the NFT use cases other than Cryptokitties

What’s the NFT ERC-721 token standard?

Aight! Let’s start! 😎

Okay, now that we know what ERC721 is (the non-fungible token standard), we can go ahead with our first step to deploy the smart contract.

Get test Ether

Assuming that you have a Metamask wallet on your browser (if you don’t have one, please get it), let’s get some fake Ethereum.

To start, open this Ropsten faucet https://faucet.ropsten.be/ and switch your Metamask to the Ropsten testnet.

Then, copy/paste your wallet address to the faucet and get some test Ether. We will need it to pay the gas fees for the Smart Contract.

Download IPFS and upload your artwork file

The majority of the NFTs data needs to be stored off-chain, and we need to secure this data.

We can solve this issue with IPFS — The InterPlanetary File System, a peer-to-peer protocol to share and store files. IPFS uses content-addressing to uniquely identify each file in a global namespace that is important for our NFTs to link the NFT metadata to where the asset or artwork is stored. Therefore, IPFS can be seen as more persistent with data pinning when compared to centralized services such as Dropbox or Google Drive.

We will use IPFS to store our NFT file. We could use Pinata, but today we will install the IPFS node and do it old school!

Head to the IPFS website and install IPFS on your desktop/laptop. Once installed, run it. Congratulations, you are now an IPFS node!

Click files and upload your “Mona Lisa”!

Once uploaded, you will have access to a sharable link. Keep it!

Open Ethereum Remix and create the Smart Contract

Now it’s time to head over to the Ethereum Remix IDE and make a new Solidity file, for example, “erc721.sol”. We will use Ethereum Remix and use the 0xcert/ethereum-erc721 contract to create our NFT Smart Contract.

Ethereum Remix is an open-source web app that allows you to develop, compile and deploy smart contracts. Pretty slick!

Copy/paste the following script to your newly created .sol file:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import "https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol";
import "https://github.com/0xcert/ethereum-erc721/src/contracts/ownership/ownable.sol";

contract newNFT is NFTokenMetadata, Ownable {

constructor() {
nftName = "Synth NFT";
nftSymbol = "SYN";
}

function mint(address _to, uint256 _tokenId, string calldata _uri) external onlyOwner {
super._mint(_to, _tokenId);
super._setTokenUri(_tokenId, _uri);
}

}

As you can see here, we are going to import the 0xcert/ethereum-erc721 contracts. Other than that, this script is pretty much self-explanatory but let me know if you need help with it!

Now, you need to go and compile it. It should look something like this:

Okay, once the Smart Contract is compiled, time to deploy it!

Deploy the Smart Contract using Inject Web3 and make sure it’s connected to your Metamask’s Ropsten testnet.

Once you click deploy, it will prompt your Metamask to confirm the contract deployment.

Click confirm to go ahead and deploy the contract. In this case, we are paying our gas fees in test Ether, but if you use the main Ethereum network, you will have to pay real fees to the miners.

Congrats! Your Smart Contract is now deployed!

You can even go to Etherscan to check your new Smart Contract!

Mint the NTF

Now go to the Deployed Contracts section and expand your smart contract.

Also, expand the mint function and add the following details:

  1. Add your Ropsten address in the _to the field

Finally, click transact and confirm your transaction on Metamask!

YAY!!! Your NFT is minted! You can mint any number of NFTs with your new smart contract! How cool!

To check that you really minted an NFT, you can see it on Remix or check the transaction by clicking on Metamask and then view on Etherscan https://ropsten.etherscan.io/tx/0xfd78181dfacc866804e50f731c482d33c002301f51d498dc32d50fce8419539b

Congratulations! You have created your own NFT Smart Contract and NFT token from scratch! You can now send it to a friend or sell it for a million dollars! 😛😎🦄 Kidding, you cannot sell NFTs created on a testnet.

🚀 Follow me if you like this context and also check my 🧱 blockchain and NFT course:

📖 The Complete NFTs Course

👨‍🎓 Unblockchain Course — The Brain-Friendly Blockchain Course

Source: https://medium.com/geekculture/mint-an-nft-and-erc-721-smart-contract-easy-step-by-step-4fafff151fbe?source=rss——-8—————–cryptocurrency

Time Stamp:

More from Medium