0

I am trying to calculate how many transactions can fit into a single block. I have a block limit of 5mb. How can i learn the byte size of a single submitted transaction so i can estimate how many transactions can fit into a single block. Is there a way to do it from a polkadot js api?

Thank you

1 Answer 1

1

In polkadot-js, for any Codec object (the base of any object returned in the API), there is an .encodedLength getter that returns the length. So assuming the extrinsic is signed, tx.encodedLength will have the information.

(Unsigned transactions, since they are missing the signature, etc. info, would be shorter)

1
  • It worked! Thank you!
    – cocokick
    May 5, 2022 at 19:28

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.