{ "cells": [ { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "New wallet created successfully\n", "New hotkey created successfully\n", "Active hotkey set successfully\n", "Coldkey public key: 3887b9fd2f453a11d83d34701293907f970ec2cd353b8b561eddc7dfec420c29\n", "Coldkey SS58 address: 5DLpriEcnLbYyxae1YdN19khgwMfBGTYdqTKqWBnBDUhMZJg\n", "Active hotkey public key: \n", "Signature: [72, 25, 127, 153, 211, 34, 94, 75, 66, 96, 237, 22, 208, 51, 88, 159, 10, 202, 17, 88, 96, 241, 181, 0, 224, 1, 209, 56, 56, 143, 208, 59, 220, 129, 84, 155, 106, 248, 88, 158, 197, 137, 54, 164, 67, 70, 188, 90, 117, 73, 20, 171, 118, 204, 198, 90, 8, 73, 64, 236, 60, 9, 21, 140]\n", "Coldkey SS58 address: 5DLpriEcnLbYyxae1YdN19khgwMfBGTYdqTKqWBnBDUhMZJg\n", "Hotkey SS58 address: 5HGwWTsLZ4djV1g9gx6KSZNoiapueAUd3vLLHWQHrTawT4di\n" ] } ], "source": [ "import bittensor_wallet\n", "import asyncio\n", "wallet = bittensor_wallet.PyWallet(\"my_wallet\", \"/tmp/wallet_path\")\n", "wallet.create_new_wallet(12, \"secure_password\")\n", "print(\"New wallet created successfully\")\n", "wallet.create_new_hotkey(\"my_hotkey\", \"secure_password\")\n", "print(\"New hotkey created successfully\")\n", "wallet.set_active_hotkey(\"my_hotkey\")\n", "print(\"Active hotkey set successfully\")\n", "coldkey = wallet.get_coldkey(\"secure_password\")\n", "print(f\"Coldkey public key: {coldkey.hex()}\")\n", "coldkey_ss58 = wallet.get_coldkey_ss58()\n", "print(f\"Coldkey SS58 address: {coldkey_ss58}\")\n", "active_hotkey = wallet.get_active_hotkey(\"secure_password\")\n", "print(f\"Active hotkey public key: {active_hotkey}\")\n", "message = b\"Hello, Bittensor!\"\n", "signature = active_hotkey.sign(message, \"secure_password\")\n", "print(f\"Signature: {signature}\")\n", "coldkey_ss58 = wallet.get_coldkey_ss58()\n", "hotkey_ss58 = wallet.get_hotkey_ss58(\"my_hotkey\")\n", "print(f\"Coldkey SS58 address: {coldkey_ss58}\")\n", "print(f\"Hotkey SS58 address: {hotkey_ss58}\")\n", "\n" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Password changed successfully\n" ] } ], "source": [ "\n", "# For async functions, use this helper function\n", "async def run_async(coro):\n", " return await asyncio.ensure_future(coro)\n", "\n", "# Change password\n", "change_password_future = wallet.change_password(\"secure_password\", \"new_secure_password\")\n", "await run_async(change_password_future)\n", "print(\"Password changed successfully\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" } }, "nbformat": 4, "nbformat_minor": 2 }