Polkadot - Staking Implementation

Hi Guys,

I am building a staking solution for a client on Polkadot. I am having issues is fetching the active validators and nominators for active validators in a given ERA.
I am able to get the list of active validators for the current ERA. But will there be an interface to fetch the active validators for the past era.

The below code is not working as the polkadot js li says “erasValidators” not a function.
const validators = await api.query.staking.erasValidators(era)

However, the const validators = await api.query.session.validators() retrieves the current validators. There are 1683 active validators.

But api.query.staking.erasStakers(era, validator) inferface always return “0” nominators for all the validators that are currently active.
Eg: { total: ‘0’, own: ‘0’, others: }

I am looking forward to some help on this.

1 Like

The docs suck.

See Query extras | polkadot{.js}, you may need to use map.

2 Likes

hey this forum is not a support outlet :), pls ask at https://substrate.stackexchange.com/

3 Likes