I've created a smartcontract & deployed on bsc testnet. For the past 8 weeks, i have been upgrading and testing the contract on remix and website and they always works fine. I can mint on remix and also able to mint from my front end using web3js & metamask.

Last time i tested on 14 August, everything works still fine. But suddenly it stops working the next day. Metamask gave this error:

We were not able to estimate gas. There might be an error in the contract and this transaction may fail.

What i've done to fix it:

  • manually set the gas to be higher on metamask. But i will get EVM revert error.
  • reset metamask activity
  • clear browser cache
  • test the contract on remix & bscscan to prove that smartcontract is working fine.

what was my situation around 14 august before metamask give that error:

  • i was working locally, any code changes happened locally. what been deployed online is working as usual. so if the error happened locally, i understand maybe due to my latest code error. but my deployd website with separate contract get that error too. I've succesfuly minted 30+ tokens before suddently getting that error.

this really confuses me because for past 2 months i never had this kind of issue with this same smartcontract. Also, i can call the same function directly on remix or bscscan with no problem, metamask not giving any error.

but i only get this problem when calling method from dapp, and metamask give that error. I am utterly confuse because yesterday it was all good, i've minted 30+ tokens. but suddenly next day i can't mint the next token from dapp. but i can mint from remix.

is there a metamask update that i dont know of? is there anthing about BNB chain plato upgrade that is resulting this issue?

Please help.

BscScan Contract address: 0x1c12c36a805d57b8356d9a07dd06c59cc658eaed Snip of contract code on remix:

contract TESTCONTRACT is ERC721, ERC721Enumerable, Ownable  {

uint public weiPixelPrice = 1000000 * (10 ** 18); /* Price in PEPE */
address contractOwner;

constructor(address _contractOwner) ERC721("Testorr", "TEST") {
    contractOwner = _contractOwner;

/// changes the cost of minting
function setCost(uint newCost) public {
    require(contractOwner == msg.sender, "Not contract owner!");
    weiPixelPrice = newCost;

Javascript front end:

const web3 = new Web3(window.ethereum)
contract = web3.Contract(ABI,0x1c12c36a805d57b8356d9a07dd06c59cc658eaed)

tx = await contract.methods.setCost(111111).send({ from: accounts[0]});

Error message after i had pre-set gas and send transaction anyway:

"gasUsed":"21046", "blockHash":"0x8cf4c8dfc2fe5d00b4c1f2ce4b43c6a1f43a860bc745c31239c9c3f82b065765", 

code is pretty basic, but i dont get why this sudedntly stop working on front end next day, but works fine on remix and bscscan.

  • Without code it will be hard to help. Maybe you can go back to a commit that worked fine and slowly work your way up to when it didn't ?
    – Torof
    Commented Aug 17, 2023 at 14:42
  • i last commit on weekend. the dapp was fine, i was able to mint many tokens. no further commit made. but next day, i get that error on metamask. but still the contract works fine on remix. im editing my post to include code now.
    – adi farhan
    Commented Aug 17, 2023 at 15:05
  • have you tried to see more information about the error with your in browser console? Tha could give more information, such as precise error name or number, where the problem comes from ...
    – Torof
    Commented Aug 17, 2023 at 15:13
  • yes i had tried debugging using browser console, the only error name i got is mostly from metamask saying "cannot estimate gas, might be error in contract". so i tried pre-set the gas limit, but will then get EVM revert error (as per in original post). I've drilled down that it's not just issue with calling 1 method, but any method that involves passing data to metamask & writing to contract. Reading from contract works fine. what could be the reason for this sudden error? can you suggest any other way to debug this?
    – adi farhan
    Commented Aug 17, 2023 at 15:27
  • @adi farhan are you able to figure out the issue? I am currently facing same issue as well. What i understand us web3 version 4.0.1 or lesser is working fine but when i upgrade this version to 4.1.x it gives error. No idea why Commented Oct 14, 2023 at 22:13

2 Answers 2


In your javascript front end:

enter image description here

you have .setCost("whatever new value")

You give it a string when it should be a uint.

  • that's just an example, i would have put the actual numbers in that. i have now edit the original post to include actual value.
    – adi farhan
    Commented Aug 18, 2023 at 8:50
  • is there something wrong with the way i establish connection to web3? or because i dont specicy the "to" parameter in the send? but this all were working fine the day before, commit & deployed, minted 30+ tokens succesfully, so why next day suddenly error? could you please any unique or fresh perspective of what could be the issue here?
    – adi farhan
    Commented Aug 18, 2023 at 10:01

it seems to be a problem with the latest release, method .call() works fine but .send() not working.

Solution: downgrade to use [email protected] instead of web3@latest that'll be a temporary fix while the mods in web3js discord investigate.

meanwhile, im using ether js to replace web3js. its working ok for me now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.