Skip to main content

Python SCALE Codec Library for Polymesh

Project description

This project is forked from https://github.com/polkascan/py-scale-codec

Python Polymath SCALE Codec

Latest Version Supported Python versions

Python Polymath SCALE Codec Library

Description

Most of the data that the Substrate RPCs output is encoded with the SCALE Codec. This codec is used by the Substrate nodes' internal runtime. In order to get to meaningful data this data will need to be decoded. The Python SCALE Codec Library will specialize in this task.

Documentation

https://polkascan.github.io/py-scale-codec/

Installation

pip install polymath-scalecodec

Examples

Decode a SCALE-encoded Compact<Balance>

RuntimeConfiguration().update_type_registry(load_type_registry_preset("default"))
RuntimeConfiguration().update_type_registry(load_type_registry_preset("kusama"))
obj = ScaleDecoder.get_decoder_class('Compact<Balance>', ScaleBytes("0x130080cd103d71bc22"))
obj.decode()
print(obj.value)

Add custom types to type registry

RuntimeConfiguration().update_type_registry(load_type_registry_preset("default"))

custom_types = {
    "types": {
        "MyCustomType": "u32",
        "CustomNextAuthority": {
          "type": "struct",
          "type_mapping": [
             ["AuthorityId", "AuthorityId"],
             ["weight", "AuthorityWeight"]
          ]
        }
    }
}

RuntimeConfiguration().update_type_registry(custom_types)

Or from a custom JSON file

RuntimeConfiguration().update_type_registry(load_type_registry_preset("default"))
RuntimeConfiguration().update_type_registry(load_type_registry_file("/path/to/type_registry.json"))

License

https://github.com/PolymathNetwork/py-scale-codec/blob/master/LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polymath-scalecodec-0.3.17.tar.gz (213.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polymath_scalecodec-0.3.17-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

Details for the file polymath-scalecodec-0.3.17.tar.gz.

File metadata

  • Download URL: polymath-scalecodec-0.3.17.tar.gz
  • Upload date:
  • Size: 213.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for polymath-scalecodec-0.3.17.tar.gz
Algorithm Hash digest
SHA256 2dc78930a578eb138d9e4217d0938d6704e94ee5a206cc2f74f09584a6bf06c8
MD5 e6313e1c2a7edffb0426748a1facf89e
BLAKE2b-256 127e1eea01b0d4266151e819fa2f1fb902452be5ed757df538d40a98ac957be5

See more details on using hashes here.

File details

Details for the file polymath_scalecodec-0.3.17-py3-none-any.whl.

File metadata

  • Download URL: polymath_scalecodec-0.3.17-py3-none-any.whl
  • Upload date:
  • Size: 52.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for polymath_scalecodec-0.3.17-py3-none-any.whl
Algorithm Hash digest
SHA256 07151506060f246225a311c26e2724d9ef882d74d77c0eacbdff388a6c7eecb3
MD5 07b0e85cf528b8e8016115012865c4f7
BLAKE2b-256 65af688f2043ac7a9529f624d3109a03168090b54445ef83ee00876f6acd1612

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page