what you mean by this?
Iām just assuming html is executed sequentially each line down the page.
And the onclick=āmintTokens()ā
Wonāt run, because the logic.js script were mintTokens() is, in this case hasnāt been imported yet.
Itās okay, itāll take 10 seconds to check for myself.
Okay, update.
There were a couple things wrong.
Like āfunction_nameā is supposed to be āfunctionNameā which I noticed changed in the docs.
I also set my web3 from eth based to Moralis based.
Now my function looks like this:
MintButton.onclick = async function() {
const abi = [{
"inputs": [
{
"internalType": "string",
"name": "tokenURI",
"type": "string"
}
],
"name": "mintToken",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}];
const options = {
chain: "mumbai",
address: "0x570D251af3cc07bE28d930FaB0F31cD338EaC8f3",
functionName: "mintToken",
abi: abi,
params: { "tokenURI": "build/contracts/URI/1.json" }
};
await Moralis.executeFunction(options);
};
When clicked, it returns this error:
Uncaught (in promise) Error: This contract object doesn't have address set yet, please set an address first.
at Object.ContractNoAddressDefinedError (errors.js:122)
at Object.b._processExecuteArguments (index.js:703)
at Object.b._executeMethod (index.js:719)
at Function.<anonymous> (moralis.js:6513)
at tryCatch (moralis.js:28070)
at Generator.invoke [as _invoke] (moralis.js:28300)
at Generator.next (moralis.js:28125)
at asyncGeneratorStep (moralis.js:27579)
at _next (moralis.js:27601)
ContractNoAddressDefinedError @ errors.js:122
b._processExecuteArguments @ index.js:703
b._executeMethod @ index.js:719
(anonymous) @ moralis.js:6513
tryCatch @ moralis.js:28070
invoke @ moralis.js:28300
(anonymous) @ moralis.js:28125
asyncGeneratorStep @ moralis.js:27579
_next @ moralis.js:27601
async function (async)
MintButton.onclick @ logic.js:358
https://docs.moralis.io/moralis-server/web3/web3#executefunction
can you try with contractAddress
instead of address
?
Worked like a charm.
Marking as resolved.
Will open another question in a moment.
Anyone reading this in a historical context.
Feel free to use this contract to mint NFTs ERC-721s on Polygon Testnet Mumbai
0x570D251af3cc07bE28d930FaB0F31cD338EaC8f3
If you wish to audit the code:
https://github.com/DanielMoralisSamples/25_NFT_MARKET_PLACE
https://www.youtube.com/watch?v=EMOYpgl5S1w