bt-decode is a Python wrapper around the high-performance Rust `scale-codec` crate, designed for rapid scale-decoding of Bittensor data structures. As of version 0.8.0, it provides essential tools to decode various Bittensor-specific information, including `DelegateInfo`, `NeuronInfo`, `NeuronInfoLite`, and `SubnetInfo`. The library maintains an active development and release cadence, with frequent updates to ensure compatibility and introduce new features.
pip install bt-decodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a (mock) Bittensor subtensor connection and use `bt_decode.DelegateInfo.decode_from_bytes` to parse a raw hexadecimal byte string representing Bittensor delegate information into a structured Python object. This pattern is similar for other Bittensor data structures like `NeuronInfo`.
Review your code for `AccountId` decoding and adapt to alternative methods provided by the library or handle its removal appropriately. Consult the Bittensor documentation for updated data structures if needed.
Exercise caution when using string-based decoding/encoding. Prefer explicitly defined data structure classes (e.g., `DelegateInfo`) if available and stable. Monitor changelogs for updates on these features if you rely on them.
Ensure you upgrade to `bt-decode` version 0.8.0 or newer if you are using or planning to use Python 3.14.
Install the package using pip: `pip install bt-decode`. If using a virtual environment, ensure it is activated.
Ensure that the data being passed to bt-decode's functions, or any data you intend to decode, is a bytes object. If you have a hexadecimal string, convert it to bytes first (e.g., `bytes.fromhex(hex_string)`).
Install Rust and Cargo (recommended via `rustup.rs`) and ensure your system has C/C++ build tools (e.g., `build-essential` on Debian/Ubuntu, Xcode Command Line Tools on macOS, or Visual C++ Build Tools on Windows).
Create and activate a Python virtual environment (`python3 -m venv .venv && source .venv/bin/activate`) and then install the package within it (`pip install bt-decode`). Alternatively, if you understand the risks, you can override this by using `pip install --break-system-packages bt-decode`.