2

Polkadot has this:

enter image description here

And I hope I can have one for my parachain. There is a session pallet on my parachain. And the session period is readable from the constant.

So, I think this is possible.

2 Answers 2

1

This is a more generalized answer to this, specifically in Rust code and from within the Runtime.

1

If what you want is the %, then you need to get the sessionProgress and the sessionLength:

const progress = await api.derive.session.progress();
const total = progress.sessionLength;
const value = progress.sessionProgress;
console.log((value/total)*100);
1
  • I think this only works with solo babe + staking. Mar 6, 2023 at 4:02

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.