Skip to content

Conversation

@enduserrr
Copy link

Description

Summary

Added an optional x_handle field to SubnetIdentity to enable subnet owners to register their X (twitter) handle on-chain.

Changes

  • Modified bittensor/core/chain_data/subnet_identity.py:
    • Added x_handle: Optional[str] = None to the dataclass
    • Updated _from_dict to extract the handle using decoded.get("x_handle").
  • Added tests/unit_tests/test_subnet_identity.py:
    • Created a new unit test file to verify parsing logic.
    • Backward Compatibility
    • Used .get("x_handle") instead of direct key access.
      This ensures the SDK does not crash when communicating with older nodes or subnets that have not yet set an X handle (legacy data compatibility).

Tests include:

  1. Legacy data (with NO x_handle)
  2. New valid data (with x_handle)
  3. Explicit None
  4. Empty string (with x_handle)
  5. Extra fields (forward compatibility)
  6. Direct init (constructor test to verify x_handle defaults to None)

Added `x_handle` (Optional[str]) to the SubnetIdentity dataclass to get X (twitter) handles in to subnet metadata.

- Updated `SubnetIdentity` dataclass and `_from_dict` method.

- Used `.get("x_handle")` ensures compatibility with nodes or subnets that do not have this field yet

- Added unit tests covering legacy data, explicit None, empty string, and extra fields
@cuteolaf
Copy link

There's no field for X links in the Subnet Identity.
You need a chain upgrade first.

@basfroman
Copy link
Collaborator

Hey @enduserrr,

  1. You have to read https://github.com/opentensor/bittensor/blob/master/contrib/CONTRIBUTING.md
  2. If you want to apply this logic to SDK, you want to create issue about adding new field to SubnetIdentity to subtensor repo first

Copy link
Contributor

@thewhaleking thewhaleking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this attribute on the chain? I don't see anything for this in the Subtensor repo.

@cuteolaf
Copy link

cuteolaf commented Dec 1, 2025

It's not on chain yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants