ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.46k stars 953 forks source link

Gas estimation failed error improvement #1067

Open PatrickAlphaC opened 3 years ago

PatrickAlphaC commented 3 years ago

Right now, when I try to call a function that has some sort of "bad math" or uses some token that I don't have enough of, it gives a very arbitrary gas estimation failed error.

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
The execution failed due to an exception. Reverted

It would be great if it gave a little insight into where the issue was being made. For example, if I deploy this contract on Kovan: https://remix.ethereum.org/#version=soljson-v0.6.6+commit.6c089d02.js&optimize=false&evmVersion=null&gist=536123b71478ad4442cfc4278e8de577

And then hit requestVolumeData, there isn't any insight into why it's failing. In this case, the contract needed to have some LINK it in.

Additionally

Maybe another work around for working with oracles at least, would be to have a Deploy and Fund button, that calls approve on an ERC20 and sends the contract some token as well.

ravsau commented 3 years ago

I had the same error on remix when actually trying to do @PatrickAlphaC's tutorial on chainlink VRF. Turns out the error was due to wrong chainlink token addresses and coordinator addresses in the solidity contract. I copied the example for Kovan testnet but was deploying on Matic mumbai testnet. When I fixed the contract code with right addresses and redeployed., the issue went away. Hopefully this info will save a few hours of debugging for the next person who is in my situation :)

ghost commented 1 year ago

I had the same error on remix when actually trying to do @PatrickAlphaC's tutorial on chainlink VRF. Turns out the error was due to wrong chainlink token addresses and coordinator addresses in the solidity contract. I copied the example for Kovan testnet but was deploying on Matic mumbai testnet. When I fixed the contract code with right addresses and redeployed., the issue went away. Hopefully this info will save a few hours of debugging for the next person who is in my situation :)

Thank you so much!

Here's the link to the price feed (Goerli Testnet): https://docs.chain.link/data-feeds/price-feeds/addresses#Goerli%20Testnet