Is your wallet on the right chain for that contract? And doublecheck all your parameters - address, ABI, function name (deposit).
It’s working now! I switched some stuff around but am using the exact same syntax as above. I have a tiny issue though. How can I call the onSuccess and onError params as they aren’t working with my const function?
I got it, I just added the handleSuccess function at the end of the create function. Thanks guys! @alex @cryptokid
Hello Tom,
I ran into the same issue “exceeds block gas limit” for useWeb3Contract only on mumbai but calling the same contract functions works perfectly fine on front end in localhost and in hardhat. I also noticed that only functions that change state are giving issues as view functions work fine. What was the solution that you used to resolve this?
Thanks,
Hey,
Yes, it’s only functions that change state which give issue. Even mine worked fine on hardhat but didn’t work on Mumbai.
The solution is to use ethers directly instead of useWeb3Contract and to specify a gasLimit of 6000000. The syntax is this:
const create = async function () {
address = "<address>"
const ethers = Moralis.web3Library;
const web3Provider = await Moralis.enableWeb3();
const gasPrice = await web3Provider.getGasPrice();
const signer = web3Provider.getSigner();
const contract = new ethers.Contract(address, ABI, signer);
const transaction = await contract.createClone({
value: ethers.utils.parseUnits("1000000000000000", "wei"),
gasLimit: 6000000,
gasPrice: gasPrice,
});
await transaction.wait(3);
await handleSuccess(transaction)
}
You can also check this out: https://v1docs.moralis.io/moralis-dapp/web3/web3
hey facing similar issue, can u share how u fixed it?
Hey @tomwhiteman
I just wanted to let you know that I’ve been working on the same issue for the past two days, and your code helped me solve the problem. I’m forever grateful!