As a developer,I want to use the interface to search this information: which can get the validator detail information like the count of nominators and the commission and others information,
1 Answer
Everything that can be read onchain is listed here.
For example, to read the commission:
console.log((await api.query.staking.validators("11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ")).commission)
Which is a Perbill
, fixed point parts per billion, and 11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ
is a totally arbitrary validator of Polkadot today.
You can directly paste this into https://polkadot.js.org/apps/#/js.
To get the count of active nominator who end up backing a validator in era:
const lastEra = (await api.query.staking.currentEra()).unwrap();
const exposures = await api.query.staking.erasStakers(lastEra, "11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ");
console.log(exposures.others.length)
To get the list of all the nominators who casted a vote for 11uMPbeaEDJhUxzU4ZfWW9VQEsryP9XqFcNRfPdYda6aFWJ
, you have to iterate the nominators
map, but I will leave that up to you to figure out.
-
why i search the exposures.others.length not same as the expore show ? exposures.others.length=302 but the the expore show 342– RoseOct 3, 2022 at 13:53
-
-
I think it is best if you ask the difference between currentEra and activeEra in a new question and we will answer it there. Oct 4, 2022 at 7:09