Gas Limit error with `useWeb3Contract`

I’m working with react-moralis and have a runContractFunction:

    const { runContractFunction: buyItem, error: buyError } = useWeb3Contract({
        abi: nftMarketplaceAbi,
        contractAddress: nftMarketplaceAddress,
        functionName: "buyItem",
        msgValue: price,
        params: {
            nftAddress: nftAddress,
            tokenId: tokenId,
        },
    })

However, I’m getting an error:

Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] 

Is there a way to manually set gas?

1 Like

I think it would be as easy as adding overrides right?

there isn’t a way now to set the gas in a parameter, usually you get that error when the transaction would generate an exception on execution

Dang. This would be a great improvement then.

I’ve worked with a number of transactions that have failed because they couldn’t estimate the gas limit, would love to see this overrides bit implemented.

1 Like