I'm encountering an issue with MetaMask showing this warning: "This transaction would have cost you extra fees, so we stopped it. Your money is still in your wallet."

Technical Details:

  • Using Viem for contract interactions
  • BSC Testnet
  • Gas Limit: 35,000,000 units (seems too high)
  • Max Fee Per Gas: 0.00000001 TBNB

Current Implementation:

const gasPrice = await publicClient.getGasPrice();
  
return walletClient.writeContract({
  // ... contract details
  maxFeePerGas: gasPrice,
  maxPriorityFeePerGas: gasPrice / BigInt(2)
});

've tried:

1. Setting custom gas limits
2. Using maxFeePerGas and maxPriorityFeePerGas
3. Letting MetaMask handle gas estimation
How can I properly handle gas estimation to prevent this MetaMask warning?
![Screenshot 2025-02-20 at 09.55.29|690x379](upload://Auem07rP1ek0TBfE5IpHW42MTVm.png)

Having the same issue here! anybody found the solution?