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

Return fee details for an Extrinsic #527

Closed
daniel-savu opened this issue May 3, 2022 · 4 comments · Fixed by #910
Closed

Return fee details for an Extrinsic #527

daniel-savu opened this issue May 3, 2022 · 4 comments · Fixed by #910
Assignees
Labels
ready to implement No significant design questions remain; this can be implemented now

Comments

@daniel-savu
Copy link
Contributor

daniel-savu commented May 3, 2022

Is there a way to check the exact final_fee that the signer of an extrinsic was charged? The best I could think of was approximating using weights. Thank you!

@lexnv lexnv added the question Further information is requested label May 9, 2022
@jsdw
Copy link
Collaborator

jsdw commented May 11, 2022

I'm not sure off the top of my head! Having a bit of a look around, I'm not sure it's obvious from the events that come back for a transaction exactly which fees were paid. There is more detail on which fees are paid here: https://wiki.polkadot.network/docs/learn-transaction-fees

It may be that the most robust way to know exactly what you paid for a transaction is to check your balance before and after submitting it (of course ignoring any non-fee amounts you may be transferring).

Perhaps it's worth asking a question at https://substrate.stackexchange.com; if you find a specific set of steps to take, we can help you run through those steps using subxt.

@jsdw
Copy link
Collaborator

jsdw commented Aug 10, 2022

Just FYI, I dug into this myself and answered your stackexchange post (https://substrate.stackexchange.com/a/4224/474). I hope that helps!

Now that I understand it better, and assuming that all turns out to be reliable (so far it seems that way), I'll consider adding a feature to subxt to return the partial_fee for some extrinsic. (you'll probably always have to manually add on any tip paid, since the tip paying stuff can vary by chain and subxt doesn't have a reliable way to get at it.

@daniel-savu
Copy link
Contributor Author

Thank you very much for your answer! We'll have a think about whether it's worth calculating this fee ourselves since the transactionPayment::TransactionFeePaid event seems to be coming soon.

@jsdw
Copy link
Collaborator

jsdw commented Sep 27, 2022

Just to add, I think that the goal here should be to add something like:

pub fn partial_fee_estimate(&self) -> u64

to SubmittableExtrinsic. This will use payment_queryInfo to return the estimated partialFee.

Later (probably a future PR depending on where the TransactionFeePaid event is up to), we could also add:

pub fn partial_fee(&self) -> u64

to TxEvents. This could look for the TransactionFeePaid event (when it exists) and use that.

We could assume that fees are calculated as they are on polkadot and use the ExtrinsicSuccess event etc (see above stackexchange link) but it's probably wrong to bake in that assumption.

@jsdw jsdw changed the title Fees charged by an extrinsic Return fee details for an Extrinsic Sep 27, 2022
@jsdw jsdw added ready to implement No significant design questions remain; this can be implemented now and removed question Further information is requested labels Sep 27, 2022
@tadeohepperle tadeohepperle self-assigned this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to implement No significant design questions remain; this can be implemented now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants