Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to find all the polkadot accounts which either have an index or have registered their identity; similar to https://polkascan.io/polkadot/account/identities and https://polkascan.io/polkadot/indices/account.

like image 871
Suryansh Singh Avatar asked Oct 30 '25 08:10

Suryansh Singh


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) […] ]
like image 181
Shawn Tabrizi Avatar answered Nov 02 '25 23:11

Shawn Tabrizi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!