1

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 1

3

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:

3
  • 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 to api.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
  • Thanks for the detailed answer and the references! Dec 20, 2022 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.