@@ -26,24 +26,26 @@ def add_stake_extrinsic(
26
26
period : Optional [int ] = None ,
27
27
) -> bool :
28
28
"""
29
- Adds the specified amount of stake to passed hotkey `uid`.
29
+ Adds a stake from the specified wallet to the neuron identified by the SS58 address of its hotkey in specified subnet.
30
+ Staking is a fundamental process in the Bittensor network that enables neurons to participate actively and earn incentives.
30
31
31
32
Arguments:
32
- subtensor: the Subtensor object to use
33
+ subtensor: Subtensor instance with the connection to the chain.
33
34
wallet: Bittensor wallet object.
34
- hotkey_ss58: The `ss58` address of the hotkey account to stake to default to the wallet's hotkey.
35
- netuid (Optional[int]): Subnet unique ID.
36
- amount: Amount to stake as Bittensor balance, `None` if staking all.
35
+ hotkey_ss58: The `ss58` address of the hotkey account to stake to default to the wallet's hotkey. If not
36
+ specified, the wallet's hotkey will be used. Defaults to ``None``.
37
+ netuid: The unique identifier of the subnet to which the neuron belongs.
38
+ amount: Amount to stake as Bittensor balance in TAO always, `None` if staking all. Defaults is ``None``.
37
39
wait_for_inclusion: If set, waits for the extrinsic to enter a block before returning `True`, or returns
38
- `False` if the extrinsic fails to enter the block within the timeout.
40
+ `False` if the extrinsic fails to enter the block within the timeout. Defaults to ``True``.
39
41
wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`,
40
- or returns `False` if the extrinsic fails to be finalized within the timeout.
41
- safe_staking (bool) : If true , enables price safety checks
42
- allow_partial_stake (bool) : If true , allows partial unstaking if price tolerance exceeded
43
- rate_tolerance (float) : Maximum allowed price increase percentage (0.005 = 0.5%)
42
+ or returns `False` if the extrinsic fails to be finalized within the timeout. Defaults to ``False``.
43
+ safe_staking: If True , enables price safety checks. Default is ``False``.
44
+ allow_partial_stake: If True , allows partial unstaking if price tolerance exceeded. Default is ``False``.
45
+ rate_tolerance: Maximum allowed price increase percentage (0.005 = 0.5%). Default is ``0.005``.
44
46
period: The number of blocks during which the transaction will remain valid after it's submitted. If
45
47
the transaction is not included in a block within that number of blocks, it will expire and be rejected.
46
- You can think of it as an expiration date for the transaction.
48
+ You can think of it as an expiration date for the transaction. Defaults to ``None``.
47
49
48
50
Returns:
49
51
success: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for
@@ -87,14 +89,11 @@ def add_stake_extrinsic(
87
89
)
88
90
else :
89
91
staking_balance = amount
90
- staking_balance .set_unit (netuid )
91
92
92
93
# Leave existential balance to keep key alive.
93
94
if staking_balance > old_balance - existential_deposit :
94
95
# If we are staking all, we need to leave at least the existential deposit.
95
96
staking_balance = old_balance - existential_deposit
96
- else :
97
- staking_balance = staking_balance
98
97
99
98
# Check enough to stake.
100
99
if staking_balance > old_balance :
@@ -200,7 +199,7 @@ def add_stake_extrinsic(
200
199
201
200
except SubstrateRequestException as error :
202
201
logging .error (
203
- f":cross_mark: [red]Add Stake Error: { format_error_message (( error ) )} [/red]"
202
+ f":cross_mark: [red]Add Stake Error: { format_error_message (error )} [/red]"
204
203
)
205
204
return False
206
205
0 commit comments