Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

estimateGas uses constant 21.9 gwei gasPrice for estimateGas #39

Open
wjmelements opened this issue Feb 7, 2019 · 1 comment
Open

Comments

@wjmelements
Copy link

GASPRICE being an Ethereum opcode (3a), it is important to supply the correct gasPrice parameter, else you will estimate the wrong amount of gas.

An example of a token that conditions on GASPRICE is TrueUSD, which spends an additional ~21k gas if the GASPRICE is sufficiently high. Supplying insufficient gas will cause the transaction to revert. Even when the amount supplied is sufficient, there is danger that transactions that estimateGas with a different gasPrice than they pay could fail deterministically.

You might also consider padding the estimated gasLimit by 50%, which is what MetaMask does, except for regular eth transfers to accounts that aren't contracts. MetaMask checks if the recipient is a contract using eth_getCode.

@wjmelements
Copy link
Author

To test a fix, compare the result of estimateGas with a gasPrice of 50 gwei vs a gasPrice of 1 wei.

Repository owner deleted a comment from vandenbrande Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants