Skip to content

Commit 6d42e04

Browse files
chideraaomcjkula
andauthored
docs: testnet tao via btcli (#582)
* docs: testnet tao via btcli * docs: fix discord link * Update docs/evm-tutorials/evm-testnet-with-metamask-wallet.md Co-authored-by: Maciej Kula <[email protected]> * Update docs/staking-and-delegation/managing-stake-btcli.md Co-authored-by: Maciej Kula <[email protected]> * Update docs/staking-and-delegation/managing-stake-sdk.md Co-authored-by: Maciej Kula <[email protected]> * docs: removed callouts --------- Co-authored-by: Maciej Kula <[email protected]>
1 parent fdf99dc commit 6d42e04

File tree

6 files changed

+375
-271
lines changed

6 files changed

+375
-271
lines changed

docs/btcli/btcli-playground.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "BTCLI Live Coding Playground"
33
---
4+
45
<link rel="stylesheet" href="https://unpkg.com/@antonz/[email protected]/dist/snippet.css" />
56

67
This page gives the user a chance to try out some BTCLI functionality right in the browser.
@@ -14,12 +15,13 @@ For a more satisfying experience, [install btcli locally](../getting-started/ins
1415
:::danger
1516
This is not a secure code execution environment. This page is for practice/education/entertainment purposes only.
1617

17-
**Do not enter the seed phrase for a wallet with *real (main "finney" network)* TAO into this or any insecure applicaiton!**
18+
**Do not enter the seed phrase for a wallet with _real (main "finney" network)_ TAO into this or any insecure applicaiton!**
1819

1920
See:
21+
2022
- [Handle your Seed Phrase/Mnemonic Securely](../keys/handle-seed-phrase)
2123
- [Coldkey and Hotkey Workstation Security](../getting-started/coldkey-hotkey-security)
22-
:::
24+
:::
2325

2426
## Import wallets and check balances.
2527

@@ -45,6 +47,7 @@ btcli wallet regen-coldkey \
4547
btcli wallet list --wallet.path ~/.bittensor/wallets
4648

4749
```
50+
4851
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
4952
</codapi-snippet>
5053
:::
@@ -66,6 +69,7 @@ btcli wallet balance \
6669
--wallet.path ~/.bittensor/wallets \
6770
--network test
6871
```
72+
6973
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
7074
</codapi-snippet>
7175
:::
@@ -88,16 +92,22 @@ btcli wallet balance \
8892
--wallet.path ~/.bittensor/wallets \
8993
--network test
9094
```
95+
9196
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
9297
</codapi-snippet>
9398
:::
9499

95-
96100
## Transfer
97101

98-
Transfer some Tao from playground-test1 to playground-test2. We can get the `--destination` address from the `wallet list` command above.
102+
Transfer some TAO from `playground-test1` to `playground-test2`. We can get the `--destination` address from the `wallet list` command above.
103+
104+
:::info
105+
106+
- The command returning a `request failed` response in the browser does not mean that the request failed on-chain. To confirm, check the wallet balance of `playground-test2` using the command above.
107+
- You can also replace the wallet address under the `--destination` flag to transfer testnet TAO to your address.
108+
:::
99109

100-
Note: Just because the transaction fails to display in the browser below does not mean it failed on-chain. Check playground-test2's balance using the above command.
110+
Run the following command to transfer testnet TAO:
101111

102112
:::tip run it!
103113

@@ -118,42 +128,49 @@ btcli wallet transfer \
118128
--no-prompt \
119129
--wallet.path ~/.bittensor/wallets
120130
```
131+
121132
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
122133
</codapi-snippet>
123-
124-
:::info Challenges
125-
1. Check your balance to make sure the transfer executed successfully on chain.
126-
2. Switch the values to transfer TAO back from `playground-test2` to `playground-test1`.
127-
3. Transfer some testnet TAO to a wallet you manage on another device. Just please don't take all of it.
128-
4. If you have some extra testnet TAO, transfer some to the playground-test wallets to refill them.
134+
:::
129135

130-
*Note: Testnet TAO has no monetary value.*
136+
:::info Challenges
131137

132-
:::
138+
1. Check your balance to make sure the transfer executed successfully on chain.
139+
2. Switch the values to transfer TAO back from `playground-test2` to `playground-test1`.
140+
3. Transfer some testnet TAO to a wallet you manage on another device. Just please don't take all of it.
141+
4. If you have some extra testnet TAO, transfer some to the playground-test wallets to refill them.
133142

143+
_Note: Testnet TAO has no monetary value._
144+
145+
:::
134146

135147
## Subnets
148+
136149
### Subnet list
137150

138151
:::tip run it!
139152
<codapi-settings url="https://bittensor-codex.com/v1">
140153
</codapi-settings>
154+
141155
```shell
142156

143157
btcli subnet list
144158
```
159+
145160
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
146161
</codapi-snippet>
147162
:::
148163

149-
150164
### Subnet show
165+
151166
:::tip run it!
152167
<codapi-settings url="https://bittensor-codex.com/v1">
153168
</codapi-settings>
169+
154170
```shell
155171
btcli subnet show --netuid 3
156172
```
173+
157174
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
158175
</codapi-snippet>
159176
:::
@@ -175,9 +192,12 @@ btcli wallet regen-coldkey \
175192
btcli stake list --network test --wallet.name playground-test1 --wallet-path ~/.bittensor/wallets --no-prompt
176193

177194
```
195+
178196
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
179197
</codapi-snippet>
198+
:::
199+
200+
:::info Challenge
201+
Try staking and unstaking from the playground-test wallets!
180202

181-
:::info Challenge
182-
Try staking and unstaking from the playground-test wallets!
183203
:::
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
---
22
title: "EVM Testnet with Metamask Wallet"
33
---
4+
45
import ThemedImage from '@theme/ThemedImage';
56
import useBaseUrl from '@docusaurus/useBaseUrl';
67

78
# EVM Testnet with Metamask Wallet
89

9-
This tutorial is for how to set up your Metamask wallet to use with the testnet on Bittensor. You must run this step before you can run other tutorials in this section.
10+
This tutorial is for how to set up your Metamask wallet to use with the testnet on Bittensor. You must run this step before you can run other tutorials in this section.
1011

1112
:::tip blog post: EVM on Bittensor
1213
If you are new to EVM, try this [blog post](https://blog.bittensor.com/evm-on-bittensor-draft-6f323e69aff7) for a simplified explanation.
1314
:::
1415

1516
Key values:
17+
1618
- The **Bittensor Testnet URL:** `https://test.chain.opentensor.ai`
1719
- **EVM Subtensor Chain ID:** `945` (UTF-8 encoded alpha character)
1820
- **Opentensor EVM-Bittensor GitHub repo:** `https://github.com/opentensor/evm-bittensor/tree/main`
19-
2021

21-
## Step 1. Create a Metamask wallet
22+
## Step 1. Create a Metamask wallet
2223

2324
1. If you don't already have it, [install Metamask wallet](https://metamask.io/download/) browser extension.
2425
2. Create a new account.
@@ -27,52 +28,53 @@ Key values:
2728

2829
Add the testnet to Metamask from within the Metamask wallet. Follow the below steps:
2930

30-
1. Open Metamask Wallet extension on your browser. Click on the &#8942; (three vertical dots, i.e., vertical ellipsis) at the top right.
31-
2. Select **Settings** from the drop-down menu.
31+
1. Open Metamask Wallet extension on your browser. Click on the &#8942; (three vertical dots, i.e., vertical ellipsis) at the top right.
32+
2. Select **Settings** from the drop-down menu.
3233
3. Select **Networks** > **Add network**.
3334
4. Click on **Add a network manually** at the bottom of the networks list.
3435
5. Enter the following details:
35-
- **Network name:** "Subtensor"
36-
- **EVM RPC URL:** `https://test.chain.opentensor.ai`
37-
- **Chain ID:** `945`
38-
- **Currency symbol:** TAO
36+
- **Network name:** "Subtensor"
37+
- **EVM RPC URL:** `https://test.chain.opentensor.ai`
38+
- **Chain ID:** `945`
39+
- **Currency symbol:** TAO
3940
6. Click **Save**.
4041
7. Then click on **Switch network**.
4142

42-
With the above steps, you have successfully configured your Metamask wallet with the testnet.
43+
With the above steps, you have successfully configured your Metamask wallet with the testnet.
4344

4445
## Step 3 Obtain TAO
4546

46-
Next, request testnet TAO in the Bittensor community Discord.
47+
Next, request testnet TAO in the Bittensor community [Discord](https://discord.com/channels/799672011265015819/1107738550373454028/threads/1331693251589312553). Alternatively, you can transfer some testnet TAO to your wallet address using the [BTCLI Live Coding Playground](../btcli/btcli-playground.md#transfer).
4748

4849
## Step 4. Copy Metamask wallet private key into config
4950

5051
:::danger Stop. Did you install the dependencies?
5152
Before you proceed, make sure you finished the [Install](./install.md) step.
5253
:::
5354

54-
In this step you will copy the private key from your Metamask wallet account and paste it into the configuration file in the repo. This step will ensure that you are not prompted with password each and every step as you run these tutorials.
55-
55+
In this step you will copy the private key from your Metamask wallet account and paste it into the configuration file in the repo. This step will ensure that you are not prompted with password each and every step as you run these tutorials.
5656

5757
1. Navigate to the `examples` directory of the EVM-Bittensor repo:
5858

59-
```bash
60-
cd examples
61-
```
59+
```bash
60+
cd examples
61+
```
6262

6363
2. Create `config.js` file by copying the `config-example.js` file:
6464

65-
```bash
66-
cp config-example.js config.js
67-
```
65+
```bash
66+
cp config-example.js config.js
67+
```
6868

69-
3. On Metamask wallet extension, your wallet account will have a H160 account address, starting with the `0x` prefix (for example: `0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf`), and also your wallet account name.
70-
4. Click on your wallet account name, which will open the drop-down menu.
69+
3. On Metamask wallet extension, your wallet account will have a H160 account address, starting with the `0x` prefix (for example: `0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf`), and also your wallet account name.
70+
4. Click on your wallet account name, which will open the drop-down menu.
7171
5. Click on the &#8942; (three vertical dots, i.e., vertical ellipsis) next to the wallet account and select **Account details**. It will open a view with a QR code, your wallet account H160 address and a **Show private key** button.
7272
6. Click on the **Show private key** button, enter the password. You will then see the private key for your wallet account. Copy this private key.
7373
7. Paste this private key into `ethPrivateKey` string in your `config.js` file as shown below (mangled for security):
7474

7575
```javascript
76-
const ethPrivateKey = "02c1c4112233snipsnipsnipgh933aca491e090e0b7xxyy1b124b86d9382b01a8";
76+
const ethPrivateKey =
77+
"02c1c4112233snipsnipsnipgh933aca491e090e0b7xxyy1b124b86d9382b01a8";
7778
```
78-
Save the `config.js` file. Now your setup is ready to run the tutorials with EVM testnet.
79+
80+
Save the `config.js` file. Now your setup is ready to run the tutorials with EVM testnet.

docs/staking-and-delegation/managing-stake-btcli.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ Test network tokens have no real value. Before managing liquidity on Bittensor m
3333

3434
## View TAO balance
3535

36-
To stake, you'll first need some TAO. Inquire in Discord to obtain TAO on Bittensor test network.
36+
To stake, you'll first need some TAO. Inquire in [Discord](https://discord.com/channels/799672011265015819/1107738550373454028/threads/1331693251589312553) to obtain TAO on Bittensor test network. Alternatively, you can transfer some testnet TAO to your wallet address using the [BTCLI Live Coding Playground](../btcli/btcli-playground.md#transfer).
3737

38-
To ensure you are targeting the test network, run `btcli config set`, select network, and set it to `test`.
38+
After creating a wallet, ensure that you are targeting the test network by running the `btcli config set` command. Next, select network, and set it to `test`.
3939

4040
View your testnet balance with:
41+
4142
```shell
4243
btcli wallet balance
4344
```
@@ -65,7 +66,6 @@ btcli subnet list
6566

6667
You should see something like the following output. Notice that next to the subnets Netuid and Name is the subnet's token `Price (τ_in/α_in)`, which, as indicated, is a ratio of the TAO in reserve `τ_in` to alpha in reserve `α_in`.
6768

68-
6969
```console
7070
Subnets
7171
Network: test
@@ -119,7 +119,6 @@ Using the specified network test from config
119119
46 │ 928.60 Ⲃ │ 928.23 Ⲃ │ τ 0.38 │ 0.00439 │ 0.0088 │ 0.35965 Ⲃ │ 5GuqX1 │ 5Ehuid │ ~
120120
```
121121

122-
123122
## Stake into a node
124123

125124
Use `btcli stake add` to stake to a validator on a subnet. You'll be prompted to choose a subnet and validator, as well as specify an amount of TAO to stake into the validator's hotkey as alpha.
@@ -161,7 +160,6 @@ Using the specified network test from config
161160

162161
After selecting a validator to delegate stake to, you'll see your wallet balance and be asked to specify the amount of TAO you wish to stake.
163162

164-
165163
```console
166164
Amount to stake (TAO τ): 5
167165
```
@@ -217,17 +215,16 @@ Stake is held in alpha, but note that value at the current price is also display
217215
Press Enter to continue to the next hotkey...
218216
```
219217

220-
221218
## Transferring stake
222219

223-
224220
The `btcli stake transfer` command is used to transfer ownership of stake from one wallet (coldkey) to another.
225221

226222
:::tip
227223
Don't confuse this with `btcli stake move`, which does not transfer ownership to another wallet/coldkey, but moves stake between validators or subnets, effectively unstaking and restaking it in a single operation.
228224
:::
229225

230226
This operation effectively comprises a series of operations, which occur as an atomic transaction:
227+
231228
- first, the specified amount is unstaked from the subnet alpha token into TAO
232229
- that amount of TAO is then transferred to the ownership of the recipient
233230
- the recipient then automatically stakes the newly received TAO into the subnet, receiving the alpha tokens in return
@@ -312,5 +309,3 @@ The `btcli stake move` command is used to moves stake between validators or subn
312309
:::tip
313310
Don't confuse this with `btcli stake transfer`, which is used to transfer ownership of stake from one wallet (coldkey) to another.
314311
:::
315-
316-

docs/staking-and-delegation/managing-stake-sdk.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ See also:
1313
- [Staking/delegation overview](./delegation)
1414
- [Understanding pricing and anticipating slippage](../dynamic-tao/staking-unstaking-dtao)
1515

16-
1716
:::tip
1817
Minimum transaction amount for stake/unstake/move/transfer: 500,000 RAO or 0.0005 TAO.
1918
:::
2019

2120
## Check your TAO balance
2221

23-
To stake, you'll first need some TAO. Inquire in Discord to obtain TAO on Bittensor test network.
22+
To stake, you'll first need some TAO. Inquire in [Discord](https://discord.com/channels/799672011265015819/1107738550373454028/threads/1331693251589312553) to obtain TAO on Bittensor test network. Alternatively, you can transfer some testnet TAO to your wallet address using the [BTCLI Live Coding Playground](../btcli/btcli-playground.md#transfer).
2423

2524
:::danger
2625
The funds in a crypto wallet are only as secure as your private key and/or seed phrase, and the devices that have access to these.
@@ -161,39 +160,39 @@ async def find_top_three_valis(subtensor,subnet):
161160
netuid = subnet.netuid
162161
print(f"\n🔍 Subnet {netuid} had {subnet.tao_in_emission} emissions!")
163162
print(f"\n🔍 Fetching metagraph for subnet {netuid}...")
164-
163+
165164
start_time = time.time()
166165
metagraph = await subtensor.metagraph(netuid)
167166

168167
print(f"✅ Retrieved metagraph for subnet {netuid} in {time.time() - start_time:.2f} seconds.")
169168
# Extract validators and their stake amounts
170169
hk_stake_pairs = [(metagraph.hotkeys[index], metagraph.stake[index]) for index in range(len(metagraph.stake))]
171-
170+
172171
# Sort validators by stake in descending order
173172
top_validators = sorted(hk_stake_pairs, key=lambda x: x[1], reverse=True)[0:3]
174173

175174
# Print the top 3 validators for this subnet
176175
print(f"\n🏆 Top 3 Validators for Subnet {netuid}:")
177176
for rank, (index, stake) in enumerate(top_validators, start=1):
178177
print(f" {rank}. Validator index {index} - Stake: {stake}")
179-
178+
180179
return {
181180
"netuid": netuid,
182181
"metagraph": metagraph,
183182
"validators": top_validators
184183
}
185184

186185
async def main():
187-
async with bt.async_subtensor(network='test') as subtensor:
186+
async with bt.async_subtensor(network='test') as subtensor:
188187

189188
print("Fetching information on top subnets by TAO emissions")
190-
189+
191190
# get subnets and sort by tao emissions
192191
sorted_subnets = sorted(list(await subtensor.all_subnets()), key=lambda subnet: subnet.tao_in_emission, reverse=True)
193192
top_subnets = sorted_subnets[0:3]
194193
amount_to_stake = bt.Balance.from_tao(total_to_stake/9)
195-
196-
# find the top 3 validators in each subnet
194+
195+
# find the top 3 validators in each subnet
197196
top_vali_dicts = await asyncio.gather(*[find_top_three_valis(subtensor, subnet) for subnet in top_subnets])
198197
top_validators_per_subnet = {}
199198
for d in top_vali_dicts:
@@ -318,7 +317,7 @@ async def main():
318317

319318
# Determine how much TAO to unstake per validator
320319
amount_per_stake = total_to_unstake / len(stakes)
321-
320+
322321
# Prepare concurrent unstake tasks, then execute as a batch
323322
tasks = [
324323
perform_unstake(subtensor, stake, min(amount_per_stake, stake.stake))
@@ -329,7 +328,7 @@ async def main():
329328
# Count successes and print final report
330329
success_count = sum(results)
331330
print(f"\n🎯 Unstake complete. Success: {success_count}/{len(stakes)}")
332-
331+
333332
wallet_name = os.environ.get('WALLET')
334333
total_to_unstake = os.environ.get('TOTAL_TAO_TO_UNSTAKE')
335334
max_stakes_to_unstake = os.environ.get('MAX_STAKES_TO_UNSTAKE')
@@ -365,6 +364,7 @@ unstake_minimum = 0.0005 # TAO
365364
asyncio.run(main())
366365

367366
```
367+
368368
```console
369369
Unstaking total not specified, defaulting to 1 TAO.
370370
🔍 Using wallet: PracticeKey!

0 commit comments

Comments
 (0)