Wallet and Keyfile
The Wallet class represents a named Bittensor wallet on disk. It manages a coldkey, hotkey, and their corresponding public-key files, and provides access to the underlying Keypair objects.
from bittensor_wallet import Wallet, CRYPTO_ED25519, CRYPTO_SR25519
For the btcli equivalents of these operations, see Creating/Importing a Bittensor Wallet. For background on coldkeys and hotkeys, see Wallets, Coldkeys and Hotkeys.
Wallet structure on disk
A wallet is stored under ~/.bittensor/wallets/ by default:
~/.bittensor/wallets/
└── my-wallet/
├── coldkey # password-encrypted coldkey
├── coldkeypub.txt # unencrypted coldkey public key
└── hotkeys/
├── default # hotkey (unencrypted by default)
└── defaultpub.txt # unencrypted hotkey public key
Each file is a Keyfile. The coldkey is encrypted at rest by default; the hotkey is not.
Creating a wallet
wallet = Wallet() # uses name="default", hotkey="default"
wallet = Wallet(name="my-wallet")
wallet = Wallet(name="my-wallet", hotkey="validator-hotkey", path="/custom/path")
Wallet(...) only constructs the object — it does not create keys or touch disk.
Generate new keys
wallet.create() # generates new coldkey and hotkey, prompts for coldkey password
wallet.create_if_non_existent() # only creates if the keys don't already exist
To create ED25519 keys instead of the default SR25519:
wallet.create(
coldkey_crypto_type=CRYPTO_ED25519,
hotkey_crypto_type=CRYPTO_ED25519,
)
To suppress interactive prompts and skip password encryption (for scripts/automation):
wallet.create(
coldkey_use_password=False,
hotkey_use_password=False,
overwrite=False,
suppress=True,
)
The same coldkey_crypto_type / hotkey_crypto_type parameters are available on create_if_non_existent() and recreate().