async function mint() {
var MintAmount = mintAmnt ;
var userAddy = Moralis.User.current();
var pricePrNft = 0.1 ;
var priceToPay = MintAmount*pricePrNft ;
const web3Provider = await Moralis.enableWeb3();
const web3Js = new Web3(Moralis.provider);
const ethers = Moralis.web3Library;
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner();
const ADDRESS =Address;
const ABI = abi;
const contract = new ethers.Contract(ADDRESS, ABI, signer) ;
contract.mint(userAddy,priceToPay)
}
i tried this at first, if i use web3Provider in the contract line instead of signer and i just call the name function of my contract and consolelog it i can see the contract name, so the contract is well linked but when i try to call the mint function it asks me for a signer and here is where im stuck, i googled and read evrything i could find about the signer but couldnt find an solution that would work for me.
Then i also tried this :
async function mint2(){
var userAddy = Moralis.User.current();
const web3 = await Moralis.enableWeb3();
var MintAmount = mintAmnt ;
var pricePrNft = 0.1 ;
var priceToPay = MintAmount*pricePrNft ;
const ADDRESS = Address;
const ABI = abi;
const options = {
contractAddress: ADDRESS ,
functionName: "mint" ,
abi: ABI ,
params: {
_to: userAddy ,
_mintAmount: MintAmount
}
}
await Moralis.executeFunction(options) ;
}
and this code above returns a huge error . Could someone help me out please ?