-
Notifications
You must be signed in to change notification settings - Fork 390
Introduce SubtensorApi
interface for SDK
#2862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…eat/roman/subtensor-api
thewhaleking
requested changes
May 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes, otherwise g2g
Co-authored-by: BD Himes <37844818+thewhaleking@users.noreply.github.com>
Co-authored-by: BD Himes <37844818+thewhaleking@users.noreply.github.com>
Co-authored-by: BD Himes <37844818+thewhaleking@users.noreply.github.com>
thewhaleking
approved these changes
May 7, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends: opentensor/async-substrate-interface#100 (until this PR is merged, most tests fail)
SubtensorApi
– Usage GuideThe
SubtensorApi
is a high-level, unified interface to interact with the Bittensor blockchain. It wraps both the synchronous and asynchronousSubtensor
implementations, providing modular access to chain subsystems like wallets, delegates, neurons, and more.1. Basic Synchronous Usage (default)
2. Asynchronous Usage
3. Legacy Method Support
You can enable all legacy methods from the original
Subtensor
class directly on this interface:4. Retry and Fallback RPC Nodes
Enable redundancy and resilience with fallback chains and retry logic:
5. Mock Mode for Testing
Use
mock=True
to simulate the interface without connecting to the blockchain:6. Subsystem Overview
All methods are grouped into logical modules for better organization and readability. Some methods may belong to more than one group if they span multiple functional areas. This does not compromise the internal logic — rather, it enhances discoverability and cohesion. Method equivalence between
SubtensorApi
and the originalSubtensor
is automatically verified by test coverage on every pull request (PR).The following properties are modular access points for specialized subsystems:
chain
commitments
delegates
extrinsics
metagraphs
neurons
queries
stakes
subnets
wallets
7. Custom Configuration Support
You can pass a pre-built
Config
object:8. Using as a Context Manager (Synchronous)
9. Using as a Context Manager (Asynchronous)