DEV Community

Cover image for Create your first NFT with Smart Contract
meetashwin
meetashwin

Posted on • Updated on

Create your first NFT with Smart Contract

In recent times, I spend most of my personal coding time with Smart Contracts. One useful resource on the internet is Road to Web3 course from folks at Alchemy.

You can follow their tutorial here to create your first smart contract and mint an NFT with it.

I am outlining the steps in this post — I suggest you to use this as a guide to using the tutorial from Web3 University.

Prerequisites

  1. Setup your MetaMask wallet and ensure a test account is setup (the tutorial uses Rinkeby network)
  2. Add some ETH to your Rinkeby test account using Rinkeby Faucet. This will give us enough gas to deploy smart contract to Ethereum network and mint it
  3. Create an account in OpenSea Testnet using the MetaMask wallet (Rinkeby account). This is where the NFT will be deployed
  4. Create a Filebase account which will host your NFT (an image for example) using IPFS

Steps to mint your first NFT

  1. Create your first ERC721 (NFT standard) smart contract in Solidity using OpenZeppelin wizard. Keep the default code, it is good enough for the test deployment
  2. Open the smart contract in Remix and understand what each section of the code does (tutorial from Web3 University guys help with it)
  3. Compile the smart contract and ensure there are no errors
  4. Deploy the smart contract using the Rinkeby test account you setup earlier in MetaMask wallet. Some ETH will be used as gas for this deployment
  5. Once the deployment of smart contract to Ethereum network is successful, focus on uploading the NFT digital asset to your Filebase bucket
  6. Go to Filebase console, create a bucket and upload the NFT + metadata.json to it (again use the tutorial to understand how to create the metadata.json file)
  7. Copy the IPFS CID for metadata.json file. We will use this to mint the NFT from the smart contract
  8. Go back to Remix and mint the NFT using the safeMint() method, which takes in 2 arguments — IPFS CID (from Filebase) and Account ID (from MetaMask wallet)
  9. Again, the minting process will use a small amount of gas. Ensure your see a success message in Remix console
  10. Go to OpenSea Testnet and login with your MetaMask wallet, using your Rinkeby test account
  11. If all went well, you should see the NFT hosted in OpenSea, with all the metadata setup using metadata.json

Congratulations on minting your first NFT using smart contract!

This post was originally published by me at Meet Ashwin.

Here’s the link to my NFT — this is an art work by my daughter!

Top comments (1)

Collapse
 
imintify profile image
iMintify

We created a No-Code Smart contract builder.. This helps all users to develop an NFT Contract for Free without a single line of code.

Image description

Check our website: imintify.com/