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

Better Gas estimation for on-chain calls #617

Merged
merged 2 commits into from
Apr 21, 2022
Merged

Better Gas estimation for on-chain calls #617

merged 2 commits into from
Apr 21, 2022

Conversation

IlyasRidhuan
Copy link
Contributor

This PR adds better gas estimation for any on-chain calls in the browser. It primarily uses etherscan's estimation api (this is wrapped behind a simple AWS gateway), but has a fallback function that uses the local node to do so.

The advantage of the etherscan api is that it has a richer estimation algorithm (with low, med and high - we use medium for this application) while the fallback relies on the average gas cost of the last n blocks.

The url endpoint is hardcoded, it will be used for all deployments of the wallet (i.e. testnet, mainnet) since etherscan only provides an estimation for mainnet. This isn't a problem as it means we get a good idea of the gas costs involved on mainnet even while testing using Goerli.

Placing the api behind an AWS endpoint means we can monitor and add throttling or restrictions if we find that they are being over-used.

Note: There is some eslint issues fixed here too

@Westlad Westlad merged commit 0864122 into master Apr 21, 2022
@Westlad Westlad deleted the estimate-gas branch April 21, 2022 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants