TrueFiEng / useDApp

Framework for rapid Dapp development. Simple. Robust. Extendable. Testable
https://usedapp.io
MIT License
1.59k stars 369 forks source link

Incorrect estimation of the gas limit, when wanting to execute an external function in a contract #905

Closed RetroDefi closed 2 years ago

RetroDefi commented 2 years ago

Describe the bug Apparently in useDapp, when wanting to execute an external function in a smart contract, it incorrectly estimates the gas limit, causing the transaction to be rejected due to insufficient gas.

To Reproduce It can be easily reproduced with a contract similar to this one that is deployed on BSC Mainnet which is a pancake yield farm strategy.

https://bscscan.com/address/0x45014e81a703dadDe911a91256c7718809fe448D#writeContract

you can generate the action button in the "Earn" function and verify the gas that is proposed in the metamask wallet, then try to generate the same transaction in the "Earn" function on the bscscan website and verify the gas proposed in the metamask wallet, noting in a simple way that the gas proposed by a website that uses UseDapp will be showing a lower gas limit causing the transaction to be rejected

Software versions

Additional context Screenshot_806 Screenshot_805

ssuvorov commented 2 years ago

I was trying to set a gasLimit in a send fn, also doesn't work fn.send(arg1, arg2, { gasLimit: 700000 }

rzadp commented 2 years ago

I was trying to set a gasLimit in a send fn, also doesn't work fn.send(arg1, arg2, { gasLimit: 700000 }

This should be fixed by https://github.com/TrueFiEng/useDApp/pull/909

RetroDefi commented 2 years ago

I was trying to set a gasLimit in a send fn, also doesn't work fn.send(arg1, arg2, { gasLimit: 700000 }

This should be fixed by #909

The problem continues despite the fact that this bug has been marked as solved, although you can actually use a "gasLimit" by adjusting it manually, the most advisable thing would be for ethers to do it automatically,

*NOTE, the problem started to appear after adding the limit gas buffer