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

Add support for estimate fees and simulate transactions #411

Closed
VenkatTeja opened this issue Mar 11, 2024 · 3 comments
Closed

Add support for estimate fees and simulate transactions #411

VenkatTeja opened this issue Mar 11, 2024 · 3 comments

Comments

@VenkatTeja
Copy link

As described in title, it would be good to have support for these two features. We could propose a standard and take help of wallets to do necessary integrations.

Reason for estimate fees:
DApps will be able to show precise fee to users on their UI's itself

Reason for simulate:
Dapps will be able to precisely use info on tokens in and out to give users easy clarity on what they would receive finally. Usually, this is an easy thing for simple contracts, but for projects like Hashstack.finance which involve integrations with different DeFi apps for swaps, liquidity provisions, staking etc, being able to write logic to estimate tokens output can itself be complex math. Given that the RPC supports simulation, exposing it could be easier and may even help others?

@VenkatTeja
Copy link
Author

I haven't checked the project code in detail, but if project contributors think this can be implemented, I can try working on this.

@fracek
Copy link
Contributor

fracek commented Mar 14, 2024

Hello, yes I think it would be very useful. My understanding is that we need two steps:

  • Create a new hook (useEstimateFees, usually I use the rpc method name) to estimate the fees.
  • Update the useContractWrite hook to accept the fee estimation from the previous hook.

@VenkatTeja
Copy link
Author

@fracek will try to complete this and raise a PR.

fracek added a commit that referenced this issue Apr 3, 2024
## Context
As described in the issue #411, dapps sometimes needs fees estimation
before doing the actual contract call. For this, I've created the
useEstimateFees hook.

## Changes in this Pull Request
- Added useEstimateFees custom hook.
- Added relevant documentation in the docs with usage example.
@fracek fracek closed this as completed Aug 7, 2024
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

No branches or pull requests

2 participants