I am having a similar problem but with next JS. I am following the tutorial above however this is using html and JS not a JS framework like Next JS
async function init (){
let currentUser = Moralis.User.current();
if(!currentUser){
window.location.pathname="/index.js"
}
web3 = await Moralis.Web3.enable();
let accounts = await web3.eth.getAccounts();
console.log(accounts);
const urlParams = new URLSearchParams(window.location.search);
const nftId = urlParams.get("nftId");
document.getElementById("token_id").value = nftId;
}
async function mint(){
let tokenId = parseInt(document.getElementById("token_id"));
let address = document.getElementById("address_input");
let amount = parseInt(document.getElementById("amount_input"));
}
init();
I used the code above and it says moralis is not defined I then added the code below but to no avail. At first i thought it was not needed as the moralis is initialised in the <MoralisProvider>
tag in the _app.js
.
Moralis.initialize("XEu7NpoUqsIKwOFPI1xnm5RuwCckn8QFDusfIbaA");
Moralis.serverURL = "https://e2s7tswf4xf4.moralishost.com:2053/server";
I am just tryig to call a funciton from my smart contract which would allow the user to mint an nft which allready exists on chain in the contract