-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable decode the event #64
Comments
The best (and easiest) way to read a storage function in substrateinterface is to use the event = substrate.query("System", "Events", block_hash="0x1029553d55f2aa71b164add49282ce56f643bf4ba422cb98278a2e4f32f7c8b4") But if you for some reason still need to manually decode a SCALE object, you will need to initialize the runtime (to add the type definitions from the metadata to the registry of the library). You can simply do this by added: substrate.init_runtime()
event = substrate.runtime_config.create_scale_object(
event_storage_function.get_value_type_string(), data=ScaleBytes(event_data), metadata=metadata
) But I see there is a need for a convenience function, so I will add |
There is in fact already a convenience method, check out: https://polkascan.github.io/py-substrate-interface/#substrateinterface.SubstrateInterface.decode_scale |
thanks! I have encountered a new error here, but I can't track the information. Do you have similar problems? /usr/local/lib/python3.9/dist-packages/scalecodec/base.py:732: DeprecationWarning: Use RuntimeConfigurationObject.create_scale_object() instead
warnings.warn("Use RuntimeConfigurationObject.create_scale_object() instead", DeprecationWarning) |
https://github.com/polkascan/py-scale-codec/blob/master/scalecodec/base.py#L732 |
Well I added that notice myself, so I am familiar :) Because all SCALE classes and creation of SCALE objects should run via the So see https://github.com/polkascan/py-scale-codec#multiple-runtime-configurations And an example from the metadata_decoder = substrate.runtime_config.create_scale_object(
'MetadataVersioned', ScaleBytes(metadata_node_template_hex)
)
metadata_decoder.decode() |
Because in future releases this function will be removed, this is a transition stage |
Thanks! |
return message:
The text was updated successfully, but these errors were encountered: