1

I want to do a couple of things. First, get the data of all the accounts to do a wealth distribution analysis. Second, get the data of all the accounts who have attached identity information.

I am able to do basic stuff using py-substrate-interface but I am not able to figure out the commands for fetching the data of all the accounts or accounts with identity of some kind attached.

  • Sorry if its a dumb question, are you looking at the docs & examples? https://polkascan.github.io/py-substrate-interface/ --- the team is very responsive on element: https://github.com/polkascan/py-substrate-interface/pull/120 – Nuke Jun 30 '21 at 19:49
  • @NukeManDan Yeah, I looked at the examples and it went a little over my head to be honest. Experimentally, I think the example given [here](https://github.com/polkascan/py-substrate-interface#query-a-mapped-storage-function) is the way to get the data of all the accounts. If you have knowledge of this please confirm. I still need to find a way to get the data of all accounts that have some sort of identity attached – Suryansh Singh Jun 30 '21 at 20:08

1 Answers1

4

To get an exhaustive list of all entries of a mapped storage function, you should have a look at the query_map function described at: https://github.com/polkascan/py-substrate-interface#query-a-mapped-storage-function

This example actually describes how to retrieve all accounts, in case you want to retrieve all identities, you need to transform it to:

result = substrate.query_map('Identity', 'IdentityOf')

for account, identity_info in result:
    print(f"Identity of account '{account.value}': {identity_info.value}")

You can find a list of all available storage functions per module/pallet at https://polkascan.io/polkadot/runtime-module

Arjan
  • 301
  • 1
  • 4