Doc update async subtensor example #3232
Open
+36
−1
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.
Problem Description
The documentation for the
sign_and_send_extrinsicmethod inbittensor/core/async_subtensor.pywas missing a clear example. A TODO comment (# TODO: Full clear example of sending extrinsic flow) highlighted the need for demonstrating the full flow of composing, signing, and sending an extrinsic.Without this example, users might find it difficult to understand how to correctly prepare a
GenericCallobject and use thesign_and_send_extrinsicmethod, especially in an asynchronous context.Thought Process
bittensor/core/async_subtensor.pyto understand thesign_and_send_extrinsicmethod signature and its dependency onGenericCall.compose_callAvailability: I confirmed thatAsyncSubtensorprovides a helper methodcompose_call(lines 5841+) which simplifies the creation ofGenericCallobjects using on-chain metadata.AsyncSubtensorandWallet.await subtensor.compose_call(...)to create the call object. This is a crucial step as it handles metadata and parameter validation.sign_and_send_extrinsic.response.is_successand handle potential errors.bittensorlibrary.Solution
I added a comprehensive example to the docstring of
sign_and_send_extrinsicinbittensor/core/async_subtensor.py.Added Example Code:
This addition directly addresses the TODO and provides users with a copy-pasteable template for interacting with the blockchain via extrinsics.
Contribution by Gittensor, learn more at https://gittensor.io/