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

txCost/Fee Helper? #16

Open
simondlr opened this issue Mar 14, 2019 · 3 comments
Open

txCost/Fee Helper? #16

simondlr opened this issue Mar 14, 2019 · 3 comments

Comments

@simondlr
Copy link

Hey.

A pattern I've often had to do was to either estimate the tx cost (gas * gasPrice) in wei beforehand OR after a transaction take gasUsed * gasPrice to calculate how much wei was spent in the transaction. This is used in transactions, for example, where someone withdraws ETH, to see if the balance AFTER withdrawal is correct [withdrawn ETH - tx fee to withdraw ETH].

Is this something that would be meaningful? Are there others who want a similar helper? If so, I might take a stab at it, but first want to gauge interest.

Something like:

estimatedTxCost(<contract method>, <tx data>)
or
txCost(<txReceipt>, <gasPrice>)

Unsure if this would be meaningful (or something like it). So want to hear from others.

@nventuro
Copy link
Contributor

This may be very useful, yes! A trick we sometimes do when calculating how a transaction affected balance, without taking into account gas, is to set gasPrice: 0 for that tx (which works fine on ganache). I can see however other scenarios where such a helper could be used.

@frangio
Copy link
Contributor

frangio commented Mar 26, 2019

I agree this would be very useful. I'm not sure what a nice API for it would look like. I wonder if we can do something similar to balance.tracker?

@simondlr
Copy link
Author

A trick we sometimes do when calculating how a transaction affected balance, without taking into account gas, is to set gasPrice: 0 for that tx (which works fine on ganache).

Ah yes! Really simple trick to avoid this problem. :)

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

4 participants