Skip to content

Commit c4c5077

Browse files
MichaelTrestmanMichael Trestman
andauthored
live code execution spike (#548)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip --------- Co-authored-by: Michael Trestman <[email protected]>
1 parent 6aaf36e commit c4c5077

File tree

4 files changed

+215
-12
lines changed

4 files changed

+215
-12
lines changed

docs/btcli/btcli-playground.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: "BTCLI Live Coding Playground"
3+
---
4+
<link rel="stylesheet" href="https://unpkg.com/@antonz/[email protected]/dist/snippet.css" />
5+
6+
This page gives the user a chance to try out some BTCLI functionality right in the browser.
7+
8+
The BTCLI Live Coding Playground is an ephemeral environment run in a container, meaning nothing stays in between requests, so you'll have to load in you wallet each time. For this reason, you must only use test wallets in the playground. Any coldkey used in the playground should be considered compromised.
9+
10+
The BTCLI Live Coding Playground is also experimental and a bit flakey, so if you see error responses, try again, but if they persist, the service may be down.
11+
12+
For a more satisfying experience, [install btcli locally](../getting-started/install-btcli) and try [managing stake with BTCLI](../staking-and-delegation/managing-stake-btcli)
13+
14+
:::danger
15+
This is not a secure code execution environment. This page is for practice/education/entertainment purposes only.
16+
17+
**Do not enter the seed phrase for a wallet with *real (main "finney" network)* TAO into this or any insecure applicaiton!**
18+
19+
See:
20+
- [Handle your Seed Phrase/Mnemonic Securely](../keys/handle-seed-phrase)
21+
- [Coldkey and Hotkey Workstation Security](../getting-started/coldkey-hotkey-security)
22+
:::
23+
24+
## Import wallets and check balances.
25+
26+
I've created two wallets for this tutorial and put some testnet TAO into them. Run the code below to import them into bittensor-codex(the code execution service), and list them to see their public keys.
27+
28+
### Import both wallets and list their keys
29+
30+
:::tip run it!
31+
<codapi-settings url="https://bittensor-codex.com/v1">
32+
</codapi-settings>
33+
34+
```shell
35+
btcli wallet regen-coldkey \
36+
--mnemonic "add aerobic there stool organ switch about diagram arctic vague replace seminar" \
37+
--wallet.name 'playground-test1' \
38+
--no-use-password --wallet.path ~/.bittensor/wallets
39+
40+
btcli wallet regen-coldkey \
41+
--mnemonic "nominee sort fringe gauge tank sure core memory abandon lamp alter flash" \
42+
--wallet.name 'playground-test2' \
43+
--no-use-password --wallet.path ~/.bittensor/wallets
44+
45+
btcli wallet list --wallet.path ~/.bittensor/wallets
46+
47+
```
48+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
49+
</codapi-snippet>
50+
:::
51+
52+
### Check balance for `playground-test1`
53+
54+
:::tip run it!
55+
<codapi-settings url="https://bittensor-codex.com/v1">
56+
</codapi-settings>
57+
58+
```shell
59+
btcli wallet regen-coldkey \
60+
--mnemonic "add aerobic there stool organ switch about diagram arctic vague replace seminar" \
61+
--wallet.name 'playground-test1' \
62+
--no-use-password --wallet.path ~/.bittensor/wallets
63+
64+
btcli wallet balance \
65+
--wallet.name 'playground-test1' \
66+
--wallet.path ~/.bittensor/wallets \
67+
--network test
68+
```
69+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
70+
</codapi-snippet>
71+
:::
72+
73+
### Check balance for `playground-test2`
74+
75+
:::tip run it!
76+
<codapi-settings url="https://bittensor-codex.com/v1">
77+
</codapi-settings>
78+
79+
```shell
80+
81+
btcli wallet regen-coldkey \
82+
--mnemonic "nominee sort fringe gauge tank sure core memory abandon lamp alter flash" \
83+
--wallet.name 'playground-test2' \
84+
--no-use-password --wallet.path ~/.bittensor/wallets
85+
86+
btcli wallet balance \
87+
--wallet.name 'playground-test2' \
88+
--wallet.path ~/.bittensor/wallets \
89+
--network test
90+
```
91+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
92+
</codapi-snippet>
93+
:::
94+
95+
96+
## Transfer
97+
98+
Transfer some Tao from playground-test1 to playground-test2. We can get the `--destination` address from the `wallet list` command above.
99+
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.
101+
102+
:::tip run it!
103+
104+
<codapi-settings url="https://bittensor-codex.com/v1">
105+
</codapi-settings>
106+
107+
```shell
108+
btcli wallet regen-coldkey \
109+
--mnemonic "add aerobic there stool organ switch about diagram arctic vague replace seminar" \
110+
--wallet.name 'playground-test1' \
111+
--no-use-password --wallet.path ~/.bittensor/wallets
112+
113+
btcli wallet transfer \
114+
--amount 0.1 \
115+
--wallet.name 'playground-test1' \
116+
--network test \
117+
--destination "5ESAWH9HDB9PZvs1q5j3aWF3x1wo88kwaqNcJEabGKsHMvX6" \
118+
--no-prompt \
119+
--wallet.path ~/.bittensor/wallets
120+
```
121+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
122+
</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.
129+
130+
*Note: Testnet TAO has no monetary value.*
131+
132+
:::
133+
134+
135+
## Subnets
136+
### Subnet list
137+
138+
:::tip run it!
139+
<codapi-settings url="https://bittensor-codex.com/v1">
140+
</codapi-settings>
141+
```shell
142+
143+
btcli subnet list
144+
```
145+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
146+
</codapi-snippet>
147+
:::
148+
149+
150+
### Subnet show
151+
:::tip run it!
152+
<codapi-settings url="https://bittensor-codex.com/v1">
153+
</codapi-settings>
154+
```shell
155+
btcli subnet show --netuid 3
156+
```
157+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
158+
</codapi-snippet>
159+
:::
160+
161+
## List a wallet's stakes
162+
163+
See [Staking/Delegation Overview](../staking-and-delegation/delegation).
164+
165+
:::tip run it!
166+
<codapi-settings url="https://bittensor-codex.com/v1">
167+
</codapi-settings>
168+
169+
```shell
170+
btcli wallet regen-coldkey \
171+
--mnemonic "add aerobic there stool organ switch about diagram arctic vague replace seminar" \
172+
--wallet.name 'playground-test1' \
173+
--no-use-password --wallet.path ~/.bittensor/wallets
174+
175+
btcli stake list --network test --wallet.name playground-test1 --wallet-path ~/.bittensor/wallets --no-prompt
176+
177+
```
178+
<codapi-snippet sandbox="python" editor="basic" init-delay="500">
179+
</codapi-snippet>
180+
181+
:::info Challenge
182+
Try staking and unstaking from the playground-test wallets!
183+
:::

docs/getting-started/install-btcli.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Check for the latest release at the Python Package Index: [https://pypi.org/proj
2525
Use pip to install the desired version:
2626

2727
```shell
28-
pip install bittensor-cli==9.1.0 # Use latest or desired version
28+
pip install bittensor-cli # Use latest or desired version
2929
```
3030

3131
Verify your installation and its version by running:
@@ -34,13 +34,12 @@ btcli --version
3434
```
3535
Example output:
3636
```console
37-
BTCLI version: 9.1.0
37+
BTCLI version: 9.2.0
3838
```
3939
:::warning Update frequently!
4040
Check frequently to make sure you are using the latest version of `btcli`.
4141
:::
4242

43-
4443
### Install from source
4544

4645

docusaurus.config.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,25 @@ const config = {
125125
},
126126
],
127127
],
128-
// scripts: [
129-
// // String format.
130-
// // 'https://docusaurus.io/script.js',
131-
// // Object format.
132-
// {
133-
// src: "/static/feedbug-widjet.js",
134-
// async: true,
135-
// },
136-
// ],
128+
scripts: [
129+
130+
{
131+
src:"https://unpkg.com/@antonz/[email protected]/dist/settings.js",
132+
src: "https://unpkg.com/@antonz/[email protected]/dist/snippet.js",
133+
defer: true,
134+
},
135+
136+
// String format.
137+
// 'https://docusaurus.io/script.js',
138+
// Object format.
139+
// {
140+
// src: "/static/feedbug-widjet.js",
141+
// async: true,
142+
// },
143+
],
137144
// clientModules: ["/static/feedbug-widjet.js"],
145+
146+
138147
stylesheets: [
139148
{
140149
href: "https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css",
@@ -143,6 +152,9 @@ const config = {
143152
"sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM",
144153
crossorigin: "anonymous",
145154
},
155+
{
156+
href: "https://unpkg.com/@antonz/[email protected]/dist/snippet.css",
157+
},
146158
],
147159
themeConfig:
148160
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
@@ -181,6 +193,12 @@ const config = {
181193
label: "What is Bittensor?",
182194
to: "learn/introduction",
183195
},
196+
{
197+
position: "left",
198+
label: "BTCLI Live Coding Playground",
199+
to: "btcli/btcli-playground",
200+
},
201+
184202
{
185203
position: "left",
186204
label: "EVM on Bittensor",

sidebars.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const sidebars = {
2121
// className: 'sidebarSearch', // based on Class name it will add search component
2222
// },
2323
"index",
24+
"btcli/btcli-playground",
2425
{
2526
type: "category",
2627
label: "Understand Bittensor",
@@ -113,6 +114,7 @@ const sidebars = {
113114
link: {type: "doc", id: "btcli/overview",},
114115
items: [
115116
"getting-started/install-btcli",
117+
"btcli/btcli-playground",
116118
"btcli-permissions",
117119
"btcli",
118120
"staking-and-delegation/managing-stake-btcli",
@@ -224,6 +226,7 @@ const sidebars = {
224226
"glossary",
225227

226228
],
229+
227230
};
228231

229232
module.exports = sidebars;

0 commit comments

Comments
 (0)