Categories
Ref: medium

🌐Building a Simple NFT Minting Website | by Bishal Devkota

Create app.js in the same folder: let web3;let contract;let userAccount;const contractAddress = “<YOUR_CONTRACT_ADDRESS>”;const contractABI = [ /* Paste your contract ABI here */ ];window.onload = () => {const connectButton = document.getElementById(“connectButton”);const mintButton = document.getElementById(“mintButton”);const status = document.getElementById(“status”);connectButton.onclick = async () => {if (window.ethereum) {try {await window.ethereum.request({ method: “eth_requestAccounts” });web3 = new Web3(window.ethereum);const accounts = await […]

Categories
Ref: medium

🌐 NFT Metadata & Hosting on IPFS | by Bishal Devkota

Modify your MyNFT.sol contract to include tokenURI metadata: // SPDX-License-Identifier: MITpragma solidity ^0.8.24;import “@openzeppelin/contracts/token/ERC721/ERC721.sol”;import “@openzeppelin/contracts/access/Ownable.sol”;contract MyNFT is ERC721, Ownable {uint public tokenCounter;mapping(uint => string) private _tokenURIs;constructor() ERC721(“MyFirstNFT”, “MFNFT”) {tokenCounter = 0;}function mintNFT(address recipient, string memory tokenURI) public onlyOwner returns (uint) {uint newTokenId = tokenCounter;_safeMint(recipient, newTokenId);_setTokenURI(newTokenId, tokenURI);tokenCounter++;return newTokenId;}function _setTokenURI(uint tokenId, string memory _tokenURI) internal {_tokenURIs[tokenId] = […]