I want to get extrinsic fee using polkadot.js/api.
I am checking kusama chain.
https://kusama.subscan.io/extrinsic/17981827-3
I need to get 0.00053835621
fee from above extrinsic. Which api can I use in polkadot.js/api?
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communityI want to get extrinsic fee using polkadot.js/api.
I am checking kusama chain.
https://kusama.subscan.io/extrinsic/17981827-3
I need to get 0.00053835621
fee from above extrinsic. Which api can I use in polkadot.js/api?
I am not sure how Subscan is getting this values, but I believe to get the Used Fee you have to scan the events, see this previous answer in StackExchange: Is there a way to collect fee of transaction?
In particular for fees in balance transfers, a Withdraw event will tell us the fee amount the sender account paid whereas Deposit events will tell us the amount of that fee that was deposited to the Treasury account and the amount that was deposited as tip to the block validator account
The Estimated Fee you can estimated querying the queryFeeDetails call with the extrinsic encoded. See this previous answer as an example of how to do it using PolkadotJS: Estimated fee and Used fee