How to find all the polkadot accounts with index or identity attached

Viewed 208
1 Answers

Using JS, you can simply iterate over the storage items which track this information for all accounts.

For example, to get all accounts with some Identity information, you would do:

let users = await api.query.identity.identityOf.entries()

This will return all the different storage keys and values under the identityOf storage item. Those keys will have the AccountId as the last 32 bytes of the key.

> util_crypto.encodeAddress(users[0][0].slice(-32))

"5CMbC573hpNWhJVTe4Qo7AtFQntAQDWKKVX9kt9WAHGy413y"
> users[0][1].toJSON()


{…}
​
deposit: 1666666666660
​
info: Object { additional: [], display: {…}, legal: {…}, … }
​
judgements: Array [ (2) […] ]
Related