Is there a specific reason why you manually want to decode raw SCALE-data? Because SCALE is without context, you need the exact type definition of the storage function and even specific runtime where you got that result from.. The type definitions are contained in the metadata of the runtime, where you can find the type definition of that storage function.
So the easiest way would be for example:
result = substrate.query("Identity", "IdentityOf", ["DWUAQt9zcpnQt5dT48NwWbJuxQ78vKRK9PRkHDkGDn9TJ1j"])
This function will take care of all that. You can even query historic values (state at block_hash
):
result = substrate.query("Identity", "IdentityOf", ["DWUAQt9zcpnQt5dT48NwWbJuxQ78vKRK9PRkHDkGDn9TJ1j"], block_hash="0x21b90597ae8dba9b2bfcbedc2b94bf709172477d47bb845bfe4e23af9ecc87af")
But if you insist on decoding manually, what you can try is:
storage_function = substrate.get_metadata_storage_function("Identity", "IdentityOf")
value = substrate.decode_scale(storage_function.get_value_type_string(), ScaleBytes("0x040200000002000c9924370e00000000000000000000000e4272696768746c797374616b65001a68747470733a2f2f6272696768746c797374616b652e636f6d00157374616b696e6737706340676d61696c2e636f6d00000f406272696768746c797374616b65"))
init_runtime
method in thesubstrate-interface
python package.