I'm replacing api.rpc.payment.queryInfo
with api.call.transactionPaymentApi.queryInfo
in the crawler code of Polkastats block explorer but I want to ask about the second parameter len
: is that the extrinsic lenght o what?
1 Answer
Correct.
The encoded length of the extrinsic (ref).
Why is the len parameter required? The runtime doesn't know all the decoding context of the the encoded call (ref). So you can't just pass the encoded call and calculate the length in the runtime, because it won't be able to decode it properly.
Some references that helped me unravel this:
-
Thanks, in the your referenced code the function get the lenght directly from the provided encoded extrinsic, which makes sense. Wondering why in polkadot-js you need to provide it as a different parameter. As a side note, you can pass 0 as the
len
param toapi.call.transactionPaymentApi.queryInfo
and still get the same response. Dec 19, 2022 at 17:24 -
Updated my answer which might help. When you pass 0 the fees that are calculated are incorrect Dec 20, 2022 at 8:47
-