It looks like it doesn’t find a html element with that particular id.
that is the html element calling the function sorry my post was not in the right context. i got almost every error out its just when i try to call the mint function from the front end its not reading the value of .1 ether
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
You first have to find a way to import/use Moralis sdk in your framework, then you may have to use Moralis.start instead of Moralis.initialize.
So I am using the import { useMoralis } from "react-moralis";
which I then call the useMoralis()
method from
I use the useMoralis()
function to set up the wallet interaction
You may be able to import it as a normal node module too
for the mint function?
Looking at the code and it says getTokenPrice
is there a mint command which I can put the contract address in instead of the mint address
I am looking at the api docs to see if there is something there link below
That was only an example to use Moralis sdk, not a mint function, you can make a mint function directly only with web3 too if you want. You only have to call a smart contract function.
I am a noob at solidity, I have the contract function but just struggling to call it from a DOM object
I am guessing I add the method to the button like
<div className={styles.button1} id="mint"><a>Mint</a></div>
Then call it with an onclick
function which is connected to the contract please tell me if this is wrong
That would be the idea, but you need to write more code that would call that mint function on click.
I am using this so will see how it goes…
https://docs.alchemy.com/alchemy/tutorials/how-to-create-an-nft/how-to-mint-a-nft