[SOLVED] High Gas Fee's on Rinkeby using React Moralis

Hello everyone!

I have created a simple dapp that mints an NFT for 0.01 ETH. Everything runs fine however while testing on both local and rinkeby networks, I am getting a high gas fee estimate when attempting to mint an NFT. The contract I have deployed to rinkeby is 0xc9cB8bD6bBCe97db0402A96CB54E81456DD641e8 .

The code interacting with the contract is below.

const { runContractFunction: mintNft, isFetching } = useWeb3Contract({
    abi: nftAbi,
    contractAddress: nftContractAddress,
    functionName: "mintNft",
    msgValue: value,
  });

I can mint from the contract with expected fee’s paying about 0.01021973 RinkebyETH for transaction and mint instantly.

However, when I click mint from my application I get this high gas fee estimate.


And if I do proceed, rinkeby still takes a while to pick up my transaction.

Have I implemented useWeb3Contract correctly? or is there an issue with my contract.

Just trying to figure out what may be causing this issue, as I would like to deploy to mainnet and not have users pay unncesssary gas. Thank you!

You could see how that gas fee estimate is computed. Based on gas price and the gas used. After you make the transaction you will the the exact cost.

Yes I have noticed that it does not actually take 0.05-0.08 eth only about 0.01 + some. However, seeing this while interacting with contract can be offsetting for users. Is there anyway to prevent this on my end?

You could try with a different RPC url to see if it works differently.

How are you testing locally?

I am connecting to the local hardhat node and using an account that I imported over to metamask to interact with the application.

Can you see more details on how that estimation is done? It is the gas limit or gas price or both?

Yes I can see a more detailed overview of transaction

This is after the transaction is made. I mean at estimation time.

Oh no I don’t believe so. I don’t see an option for more detailed view

You can try to click on edit

Thank you, This is what I see for a max fee of 0.0647 eth

Metamask insists on having a gas limit of 29021272 for transaction to proceed.

Yes, somehow that gas limit is too big. If you use ethers directly you could set that gas limit.

Ok I will switch to that and expriment with it. Setting it manually is working fine. Thank you for your fast responses!

1 Like