Hello,
I forked a website, and forked the contract, it is a Baked Beans fork on MATIC, source files and contract are directly copied, and only modified names and contract address on the source files.
I deployed the contract through Remix, now when I try to deposit on the website, Metamask says
"We were not able to estimate gas. There might be an error in the contract and this transaction may fail."
It gives me a gas fee of around 26 MATIC.
So you mean you can deploy your contracts with Remix, but you can not do this by your website, right? If so, I think maybe there is something wrong your website rather than the contract itself, have a check which contract will it deploy actually when you use website.
My website is an investment platform where anyone can connect with their metamask wallet, deposit, restake, and withdraw MATIC to/from the contract.
Here is where I'm at:
Website works with original contract from where I forked the project from.
I created my own fork of the contract (identical to original contract), when I deploy the contract in Remix, deployment works fine.
I change the config file by replacing the original contract address with mine.
Now the website no longer allows transactions (gives me that gas error, and when I manually set a lower gas fee, it reverts)
Why would the website script work fine with the original contract, but when I replace that contract with mine, which is just a copy of theirs, it fails?
I scanned every file for their contract address and replaced it with mine.. am I missing anything?
Also to add to my previous message,
On mobile metamask browser:
Website fork with the original contract works
Replace contract address with mine, metamask authenticates and the site shows my MATIC balance, but when I click on Buy, nothing pops up (should be popping up with Metamask payment)
Update,
I tried changing the contract address with 2 other contract addresses of other identical forks. They all worked, but the second I switch to my contract address it throws that error.
Does it maybe take a while before it starts estimating the correct gas fees? Or do I need to make multiple transfers first?
I'm completely lost at this point. Why would my website work with every other contract address except for mine, even though it's identical
Update 2,
Even directly sending MATIC to my contract address, it fails and says:
"Warning! Error encountered during contract execution [execution reverted]"
Tried playing around with gas fees, no luck. Must mean something wrong with my contract. But what?
I did realize last night that direct transactions cannot be sent to it, has to be done through the website, or by executing the buy eggs command. Now I'm back at square one. Website works with original contract that I copied from, but when I replace it with my contract (identical), I get the gas estimation error, and when I set manual gas fees, it fails with the reverted error.
Polygon network always got some problems with estimate gas, to be sure you do not got ant problems with contracts try to set GasPrice + 30 Gwei, If tx pass, that's problem with your gas estimation, if not that's problem with contract.
Did you ever solve this issue? I am doing almost the same thing and having the same problem. I have a Python script that interacts with the original contract without a problem, but I get this same issue if I interact with my contract.
I think I figured it out... at least it worked for my issue. On this contract, you have to use the "SeedMarket" function to add initial funds to the contract, then the other functions should work.
I did face this issue recently and I have been tryna figure out what really was going wrong with my contract, then figured that only the owner had the perms to call that specific function and I had to enable the perms for all to let anyone address call the function, due to which the transaction was being reverted, of course internally this could be one of the many reasons we might come across, not the only definitive solution or aspect to look at when confronting such an error.