Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Transaction fee estimation? #1223

Closed
xlc opened this issue Dec 6, 2018 · 1 comment
Closed

Transaction fee estimation? #1223

xlc opened this issue Dec 6, 2018 · 1 comment
Labels
Z7-question Issue is a question. Closer should answer.

Comments

@xlc
Copy link
Contributor

xlc commented Dec 6, 2018

I have few questions regards to transaction fee.

  1. What is the best way to estimate transaction fee? It seems like it can be calculated by using transaction size and fees from configurations, however this won't work if the modules is charging additional transaction fee (e.g. gas fee from contract module).
  2. Is there a way to dry run a transaction? Because it is not possible to create a formula to calculate transaction fee (due to dynamic nature of the modules), the best way I think is dry run a transaction, and check how much fee is been deducted. The tricky part is to determine how much of the balance deduction is from transaction fee. It will be best if user can dry run a transaction and get the delta state as response. Then it is possible to estimate the effects for any kind of transactions.
  3. There seems no way to specify gas limits for a transaction (other than contract module)? That means user doesn't have the ability to limit the cost of a transaction. Hypothetically, it is possible user broadcast a transaction and before it get finalized, the cost of gas price doubled. Or whatever changes cause the transaction fee differ to estimation that simulated on a different block.
@gavofyork
Copy link
Member

There's no particularly good way to automatically estimate transaction fees on Turing-complete smart contract platforms like Substrate-Contracts and Ethereum. In Parity Ethereum, we used a binary chop in order to figure it out, which though it works well for a lot of contracts, still isn't general.

Much better would be to annotate gas requirements as part of the contract's ABI and perhaps auto-generate this from the EDSL in which the contract is written. But that'll take Quite Some Time. In the meantime, I suggest you just use heuristics for the basic transaction fee and overestimate the gas requirements and price.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z7-question Issue is a question. Closer should answer.
Projects
None yet
Development

No branches or pull requests

2 participants