Using the source from: https://github.com/DanielMoralisSamples/25_NFT_MARKET_PLACE
I’m trying to call the mintToken Function like so:
import { fs } from "fs";
async function mintTokens() {
const contractAddress = "0x570D251af3cc07bE28d930FaB0F31cD338EaC8f3";
var jsonFile = "build/contracts/MyNFT.json";
var parsed = JSON.parse(fs.readFileSync(jsonFile));
var abi = parsed.abi;
const MyNFTContract = new web3.eth.Contract(abi, contractAddress);
MyNFTContract.methods.mintToken({
"image" : "static/Images/4.Hobbit.jpg",
"name" : "Hobbit",
"description" : "A Hobbit"
}).send();
}
document.getElementById(Mintbtn).onclick = mintTokens();
I’m having trouble importing fs to format the file location for JSON.parse(**fs.readFileSync**(jsonFile));
I know there is a moralis function that can call functions in smart contract, I was trying to use it earlier today and was having problems too, If there is a complete work around I’m happy. I just want to send a smart contract function (MyNFT.mintToken) from within logic.js