I have started studying how to mint an NFT using solidity and IPFS.
The project flow is:
- Install IPFS
- Upload asset photo by IPFS and get its hash
- Create a
metadata.json
file using the above hash
{
"name": "NFT",
"description": "This image shows the true nature of NFT.",
"image": "https://ipfs.io/ipfs/QmUnMkaEB5FBMDhjPsEtLyHr4ShSAoHUrwqVryCeuMosNr"
}
4: Upload this json file to IPFS and get its hash url
https://ipfs.io/ipfs/QmNSKewexhgY4rYwPoxPgNFN7BSjeiLXJif9q5FjeCrsmg
5: Create a solidity
smart contract with a minting function. Deploy this using Polygon Mumbai network (using MATIC token).
// 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);
}
}
6: After deploying the smart contract, the NFT is minted.
Go to OpenSea testnet, chose Mumbai testnet, and insert the address of the NFT owner.
Finally see the NFT on the testnet collection.
But I want to do this programatically in JavaScript, ReactJS and web3 library. How to achieve this?