How to calculate the handling fee? #300
-
I ran into a problem. When I transferred money, the fee received through get_payment_info was incorrect. How to accurately obtain its handling fee. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I ran a test transfer with the following call: keypair = Keypair.create_from_uri('//Alice', ss58_format=42)
balance_info = substrate.query(
module='System',
storage_function='Account',
params=[keypair.ss58_address],
)
print('Balance info', balance_info.value)
call = substrate.compose_call(
call_module='Balances',
call_function='transfer_keep_alive',
call_params={
'dest': keypair.ss58_address,
'value': 600000000000
}
)
info = substrate.get_payment_info(call, keypair)
# result: {'class': 'normal', 'partialFee': 169117900, 'weight': 176532000} So the fee estimate of this call is: 169117900 plancks. After submitting this extrinsic the fee (which is defined by the sum of the events In conclusion, I don't see anything wrong with this function, but of course I encourage you to proof me wrong ;)
The (optional) tip that you can specify when creating an extrinsic is really treated like a tip, the validator will first select the extrinsic (=transaction) that has the most tip, then transactions that has no tip. So basically this is only useful when the transaction pool is full and you want to pay extra to be processed first. So at the moment for Polkadot/Kusama this is not necessary yet, hundreds of transactions per block is no problem for Substrate. |
Beta Was this translation helpful? Give feedback.
-
You can specify the tip when creating the extrinsic: https://polkascan.github.io/py-substrate-interface/#substrateinterface.SubstrateInterface.create_signed_extrinsic |
Beta Was this translation helpful? Give feedback.
-
thank you! |
Beta Was this translation helpful? Give feedback.
I ran a test transfer with the following call: