{"id":6554,"library":"bt-decode","title":"Bittensor Data Structure Decoder","description":"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.","status":"active","version":"0.8.0","language":"en","source_language":"en","source_url":"https://github.com/opentensor/bt-decode","tags":["bittensor","scale-codec","decoding","blockchain","cryptocurrency"],"install":[{"cmd":"pip install bt-decode","lang":"bash","label":"Install bt-decode"}],"dependencies":[{"reason":"Commonly used in conjunction with bt-decode for setting up a subtensor connection to fetch data for decoding.","package":"bittensor","optional":true}],"imports":[{"symbol":"DelegateInfo","correct":"from bt_decode import DelegateInfo"},{"symbol":"NeuronInfo","correct":"from bt_decode import NeuronInfo"},{"symbol":"NeuronInfoLite","correct":"from bt_decode import NeuronInfoLite"},{"symbol":"SubnetInfo","correct":"from bt_decode import SubnetInfo"}],"quickstart":{"code":"import bittensor\nfrom bt_decode import DelegateInfo\n\n# NOTE: For a real scenario, 'subtensor' would connect to a Bittensor network\n# and 'hex_bytes_result' would be actual data fetched from the chain.\n# This example uses placeholder data for demonstration.\n\n# Setup a mock subtensor connection (in a real app, this would connect)\nclass MockSubtensor:\n    def __init__(self):\n        pass\n\n    def get_delegated_v2(self, *args, **kwargs):\n        # This is placeholder hex bytes for a DelegateInfo object\n        # In a real scenario, this would come from a live Bittensor chain.\n        # The actual bytes would vary.\n        return \"0x0c00000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000200000000000000020000000000000003000000000000000300000000000000\"\n\nsubtensor = MockSubtensor()\n\n# Assume we fetched raw hex bytes (e.g., from subtensor.get_delegated_v2())\n# This is a simplified placeholder.\nraw_hex_bytes = subtensor.get_delegated_v2() # Example call\n\n# Decode the raw hex bytes using DelegateInfo\ntry:\n    decoded_delegate_info = DelegateInfo.decode_from_bytes(bytes.fromhex(raw_hex_bytes[2:]))\n    print(f\"Successfully decoded DelegateInfo: {decoded_delegate_info}\")\nexcept Exception as e:\n    print(f\"Error decoding: {e}\")","lang":"python","description":"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`."},"warnings":[{"fix":"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.","message":"The `AccountId` decoding functionality was removed in version 0.8.0. Code relying on direct `AccountId` decoding will break.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"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.","message":"Features for 'decode by type string' and 'encode by type string' are marked as unstable. While they may work for multiple types, their API or behavior might change in future releases without major version bumps.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"Ensure you upgrade to `bt-decode` version 0.8.0 or newer if you are using or planning to use Python 3.14.","message":"Compatibility for Python 3.14 was explicitly added in version 0.8.0. Users on older `bt-decode` versions (prior to 0.8.0) might encounter issues or lack full support when running with Python 3.14.","severity":"gotcha","affected_versions":"<0.8.0"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}