Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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

Metadata

Release files for polymath-scalecodec 0.3.20b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polymath-scalecodec 0.3.20b1
File Size Uploaded
polymath-scalecodec-0.3.20b1.tar.gz 213.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polymath-scalecodec 0.3.20b1
File Interpreter ABI Platform
polymath_scalecodec-0.3.20b1-py3-none-any.whl Python 3 none any Details

Total release size: 266.5 kB

Release files / polymath-scalecodec-0.3.20b1.tar.gz

Download URL polymath-scalecodec-0.3.20b1.tar.gz
Size 213.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dab89796abc02b1059c52755a518d6a42767818939bfc91c53c75d51009ae55c
BLAKE2b-256 checksum
How to use checksums
e9c56e22cf803e4bb1866d737ea6ff812d08a1d6b04612ce9f3490a5c7822d18
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / polymath_scalecodec-0.3.20b1-py3-none-any.whl

Download URL polymath_scalecodec-0.3.20b1-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d56d0815327fa5eefc5b6951071615c9e90cc39db2c0759ac885ae94a32748ab
BLAKE2b-256 checksum
How to use checksums
967c37072c10eae546e0a78530743655c01d7c9c54e545d791cc72b6f1bee453
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

4.0.0

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.6.1

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.20

2 release files

This release

0.3.20b1 This release

2 release files

0.3.19

2 release files

0.3.16

1 release file

0.3.15

1 release file

0.3.14

1 release file

0.3.13

1 release file

0.3.12

1 release file

0.3.11

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page