Is it possible to get the average length of time (in UNIX time) per block on Substrate?

I basically want the average session length in UNIX time. I know we can get it in terms of block numbers. But I somehow need to convert block numbers to UNIX time.

1 Answer 1


After getting the number of blocks in a session, you need to know what the average block time is, since you can then multiply the two and get average session length in milliseconds. This depends on the particular consensus protocol that is being used for block production, I will assume that you are using a slot-based protocol (either Aura or BABE).

When defining your runtime you will have to specify the slot duration, you can see examples here for the node and node-template. Additionally, both the Aura and BABE pallets provide getters for the slot duration: aura, babe.

Your Answer

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

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