I am trying to call mint() on a ERC721 contract which accepts two parameters: _address & tokenURI. I have the following code which I am calling from frontend:
const mintNFT = async (tokenURI)=>{
state.isMinting=true;
const contractAddress = import.meta.env.VITE_SMART_CONTRACT_ADDRESS;
const contract = new ethers.Contract(contractAddress,contractABI.abi,snap.signer);
debugger;
try {
const mint = await contract.mint(snap.walletAddress,tokenURI);
await mint.wait();
console.log("minted successfully!! ");
state.isMinting=false;
state.isMinted=true;
} catch (error) {
console.log("Error while minting! ",error);
state.isMinting=false;
}
}
But I am getting error when contract.mint() is called. I am getting this error,
Cannot assign to read only property '_events' of object '#<Web3Provider>
Currently I am using ethers.js v^5.7.2 I am also getting this warning in metamask:
We noticed that the current website tried to use the removed window.web3 API. If the site appears to be broken, please click here for more information.
I researched a lot on the internet but was not able to find the solution of this problem. May anyone else also encountered the same problem?
Deployed Smart contract (verified): https://sepolia.etherscan.io/address/0x1604Fef32d056bB14035056A12d78EBd9706680E
Thanks