Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5901,10 +5901,45 @@ async def sign_and_send_extrinsic(
wait_for_finalization: bool = False,
calling_function: Optional[str] = None,
) -> ExtrinsicResponse:
# TODO: Full clear example of sending extrinsic flow
"""
Helper method to sign and submit an extrinsic call to chain.

Example:
import asyncio
import bittensor as bt

async def main():
# Setup
wallet = bt.Wallet()
subtensor = await bt.AsyncSubtensor(network="test").initialize()

# Compose the call
# For example, a transfer call
call = await subtensor.compose_call(
call_module='Balances',
call_function='transfer_keep_alive',
call_params={
'dest': '5Dest...',
'value': 1000000
}
)

# Sign and send
response = await subtensor.sign_and_send_extrinsic(
call=call,
wallet=wallet,
sign_with='coldkey', # signing with coldkey
wait_for_inclusion=True,
wait_for_finalization=True
)

if response.is_success:
print("Transaction success:", response.extrinsic_hash)
else:
print("Transaction failed:", response.error_message)

asyncio.run(main())

Parameters:
call: A prepared Call object
wallet: The wallet whose coldkey will be used to sign the extrinsic
Expand Down