Creating/Importing a Bittensor Wallet
In Bittensor (like other cryptocurrency applications), a wallet is a tool for proving your identity, signing transactions, accessing your TAO, and managing your stake in subnets.
This page describes several different ways to instantiate your wallet keypairs into a wallet application, in order to interact with the Bittensor blockchain.
Recommended background reading:
-
For an introduction to the core concepts, see wallets and keys in Bittensor.
-
For discussion of security considerations about working with Bittensor wallets, see Coldkey and Hotkey Workstation Security.
The most critical operational goal when handling Bittensor wallets is to avoid losing or leaking your seed phrase. Make sure you Handle your Seed Phrase/Mnemonic Securely.
Creating a wallet with btcli
Creating a coldkey-only wallet
Users that will not mine, validate, manage subnets or participate in governance do not need a hotkey, and for simplicity's sake should use coldkey-only wallets.
Run the following command to create a coldkey-only wallet.
btcli wallet new_coldkey --wallet.name <my_coldkey>
For example,
btcli wallet new_coldkey --wallet.name test-coldkey
You will see the terminal output like the following, which includes your all-important seed phrase, a.k.a. the mnemonic to the coldkey.
IMPORTANT: Store this mnemonic in a secure (preferable offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.
The mnemonic to the new coldkey is: paddle disagree swamp hill innocent enemy name shrug produce steak pupil joke
You can use the mnemonic to recreate the key with `btcli` in case it gets lost.
Creating a hotkey
If you plan to validate or mine in a subnet, you must create both a coldkey and a hotkey.
First, create a coldkey as described above in the Creating a coldkey using btcli
. Then, provide this coldkey as a parameter to generate a hotkey. This will pair the hotkey with the coldkey. See below.
Use the below command to generate the hotkey. Replace <my_coldkey>
with the coldkey generated above, and <my_hotkey>
with a name for your hotkey.
btcli wallet new_hotkey --wallet.name <my_coldkey> --wallet.hotkey <my_hotkey>
For example,
btcli wallet new_hotkey --wallet.name test-coldkey --wallet.hotkey test-hotkey
You will see the terminal log like below. The mnemonic is hidden for security reasons.
IMPORTANT: Store this mnemonic in a secure (preferably offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.
The mnemonic to the new hotkey is:
**** *** **** **** ***** **** *** **** **** **** ***** *****
You can use the mnemonic to recreate the key in case it gets lost. The command to use to regenerate the key using this mnemonic is:
btcli w regen_hotkey --mnemonic **** *** **** **** ***** **** *** **** **** **** ***** *****
Make a note of the above command option regen_hotkey
showing how to regenerate your hotkey in case you lose it.
Encrypting the hotkey
By default, the hotkey is not encrypted on the device, whereas the coldkey is encrypted. To encrypt your hotkey, run this command:
btcli wallet new_hotkey --use-password
Creating a wallet using Python
Copy and paste the following three lines into your Python interpreter. Replace the string values for name
(my_coldkey
) and hotkey
(my_hotkey
) with your own.
import bittensor as bt
wallet = bt.wallet(name = 'my_coldkey', hotkey = 'my_hotkey' )
wallet.create_if_non_existent()
You will see a terminal output like this for an example wallet with name
as test-coldkey
and hotkey
as test-hotkey
. The mnemonic is hidden for security reasons.
>>> import bittensor as bt
>>> wallet = bt.wallet(name = 'test-coldkey', hotkey = 'test-hotkey')
>>> wallet.create_if_non_existent()
IMPORTANT: Store this mnemonic in a secure (preferable offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.
The mnemonic to the new coldkey is:
**** **** **** **** **** **** **** **** **** **** **** ****
You can use the mnemonic to recreate the key in case it gets lost. The command to use to regenerate the key using this mnemonic is:
btcli w regen_coldkey --mnemonic **** **** **** **** **** **** **** **** **** **** **** ****
Specify password for key encryption:
Retype your password:
IMPORTANT: Store this mnemonic in a secure (preferable offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.
The mnemonic to the new hotkey is:
**** **** **** **** **** **** **** **** **** **** **** ****
You can use the mnemonic to recreate the key in case it gets lost. The command to use to regenerate the key using this mnemonic is:
btcli w regen_hotkey --mnemonic **** **** **** **** **** **** **** **** **** **** **** ****
wallet(test-coldkey, test-hotkey, ~/.bittensor/wallets/)
Location and addresses of the local wallets
Both btcli
and the Bittensor Python SDK use a local wallet/key store. By default, this is located on your machine at ~/.bittensor/wallets
. Use the below command to list them:
tree ~/.bittensor/
You will see an output like this:
tree ~/.bittensor/
/Users/docwriter/.bittensor/ # The Bittensor root directory.
└── wallets # The folder contains all Bittensor wallets.
└── test-coldkey # The name of the wallet.
├── coldkey # The password-encrypted coldkey.
├── coldkeypub.txt # The unencrypted version of the coldkey.
└── hotkeys # The folder contains all this coldkey's hotkeys.
└── test-hotkey # The unencrypted hotkey information.
and listing out the contents of the coldkeypub.txt
file:
cd ~/.bittensor/wallets/test-coldkey
cat coldkeypub.txt | jq
{
"accountId": "0x36e49805b105af2b5572cfc86426247df111df2f584767ca739d9fa085246c51",
"publicKey": "0x36e49805b105af2b5572cfc86426247df111df2f584767ca739d9fa085246c51",
"privateKey": null,
"secretPhrase": null,
"secretSeed": null,
"ss58Address": "5DJgMDvzC27QTBfmgGQaNWBQd8CKP9z5A12yjbG6TZ5bxNE1"
}
The contents of the coldkeypub.txt
are to be interpreted as below:
- The fields
accountId
andpublicKey
contain the same value. - The
secretPhrase
andsecretSeed
are not included in the file due to the high-security nature of the coldkey. When you create your wallet, either using the Chrome extension orbtcli
, the mnemonic (secretPhrase
) is shown only once, whilesecretSeed
is not shown. - The
ss58Address
is the SS58-version of theaccountId
orpublicKey
. This is your coldkey's public address, and can be used to transfer TAO from another wallet.
Use this site SS58.org to verify the conversions between publicKey
and ss58Address
fields.
Similarly, listing out the contents of the hotkeys/test-hotkey
file:
cat hotkeys/test-hotkey | jq
{
"accountId": "0xc66695556006c79e278f487b01d44cf4bc611f195615a321bf3208f5e351621e",
"publicKey": "0xc66695556006c79e278f487b01d44cf4bc611f195615a321bf3208f5e351621e",
"privateKey": "0x38d3ae3b6e4b5df8415d15f44f * * * 0f975749f835fc221b * * * cbaac9f5ba6b1c90978e3858 * * * f0e0470be681c0b28fe2d64",
"secretPhrase": "pyramid xxx wide slush xxx hub xxx crew spin xxx easily xxx",
"secretSeed": "0x6c359cc52ff1256c9e5 * * * 5536c * * * 892e9ffe4e4066ad2a6e35561d6964e",
"ss58Address": "5GYqp3eKu6W7KxhCNrHrVaPjsJHHLuAs5jbYWfeNzVudH8DE"
}
The contents of the hotkeys/test-hotkey
file are to be interpreted as below:
- The fields
accountId
andpublicKey
contain the same value, just as seen incoldkeypub.txt
. - The
secretPhrase
andsecretSeed
are shown because the hotkey is, by default, not encrypted. - The
ss58Address
is the SS58-version of theaccountId
orpublicKey
. This is your hotkey's public address and can be used to stake/delegate to your hotkey from other wallets.
Hotkeys are for staking. Do not transfer TAO to a hotkey!