### Setup and Run ED25519 Verification Example Source: https://docs.learnbittensor.org/evm-tutorials/ed25519-verify-precompile Provides instructions to navigate to the example directory and execute the Node.js script demonstrating ED25519 signature verification using an EVM precompile. These commands are sequential steps to run the provided example. ```bash cd examples ``` ```bash node ed25519-verify.js ``` -------------------------------- ### Install Bittensor EVM Examples Repository Dependencies Source: https://docs.learnbittensor.org/evm-tutorials/withdraw-from-alice These shell commands guide you through cloning the official Opentensor EVM-Bittensor GitHub repository. After navigating into the project directory, `yarn install` is used to fetch and set up all required Node.js dependencies for running the example scripts. ```Shell git clone https://github.com/opentensor/evm-bittensor.git cd evm-bittensor yarn install ``` -------------------------------- ### Orchestrate Complete Bittensor Neuron Setup in JavaScript Source: https://docs.learnbittensor.org/evm-tutorials/neuron-precompile This comprehensive example outlines the full setup process for a Bittensor neuron. It orchestrates multiple steps including neuron registration, Axon service configuration, Prometheus metrics setup, and initial weight setting. The snippet demonstrates a typical workflow for deploying and initializing a neuron. ```JavaScript async function setupCompleteNeuron() { try { const netuid = 1; const hotkey = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"; // 1. Register the neuron console.log("Registering neuron..."); await registerNeuron(); // 2. Configure axon service console.log("Setting up axon service..."); await serveAxon(); // 3. Configure Prometheus metrics console.log("Setting up Prometheus metrics..."); await servePrometheus(); // 4. Set initial weights (if validator) console.log("Setting weights..."); await setNeuronWeights(); console.log("Neuron setup complete!"); } catch (error) { console.error("Neuron setup failed:", error); } } // Run complete setup setupCompleteNeuron(); ``` -------------------------------- ### Install Bittensor EVM Examples Repository Source: https://docs.learnbittensor.org/evm-tutorials/convert-h160-to-ss58 Clones the `evm-bittensor` GitHub repository, navigates into the directory, and installs its dependencies using Yarn, preparing the environment for running EVM examples. ```Bash git clone https://github.com/opentensor/evm-bittensor.git cd evm-bittensor yarn install ``` -------------------------------- ### Install Rust and Configure Environment Variables Source: https://docs.learnbittensor.org/local-build/deploy These commands perform a fresh installation of Rust and Cargo using the official `rustup` script, then configure the shell environment to include Cargo's binary path. This setup is a fundamental prerequisite for building and running Rust-based applications, including the local Subtensor instance. ```Shell curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh . "$HOME/.cargo/env" ``` -------------------------------- ### Install Bittensor SDK via Pip Source: https://docs.learnbittensor.org/getting-started/installation Installs the core Bittensor SDK and the `btcli` command-line interface using Python's package installer, pip. This is the standard method for installing the SDK from PyPI. ```python pip install bittensor ``` -------------------------------- ### Verify Bittensor Wallet SDK Installation Source: https://docs.learnbittensor.org/getting-started/install-wallet-sdk After installing the Bittensor Wallet SDK, this command verifies its successful installation by listing all installed Python packages. The presence of 'bittensor-wallet' in the output confirms the installation, whether from PyPI or source. ```Python pip list ``` -------------------------------- ### Install Bittensor SDK using Official Bash Script Source: https://docs.learnbittensor.org/getting-started/installation Executes an official Bittensor installation script directly from GitHub using curl and bash. This method is recommended for beginners as it handles prerequisites automatically, including Python installation. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh)" ``` -------------------------------- ### Manage Bittensor Wallets with btcli Source: https://docs.learnbittensor.org/keys/multisig This section provides `btcli` commands for managing Bittensor wallets, including regenerating public keys, viewing dashboard information, and initiating transfers. These commands are essential for interacting with your Bittensor wallets from the command line. ```Bash btcli w regen_coldkeypub --wallet.name multisig ``` ```Bash btcli view dashboard --wallet.name multisig ``` ```Bash btcli wallet transfer ``` -------------------------------- ### Verify Bittensor Wallet SDK Installation Source: https://docs.learnbittensor.org/getting-started/install-wallet-sdk Checks the installed `bittensor_wallet` SDK version to confirm successful installation. This snippet demonstrates importing the library and printing its version. ```python import bittensor_wallet print(bittensor_wallet.__version__) ``` -------------------------------- ### Install Bittensor Wallet SDK from PyPI Source: https://docs.learnbittensor.org/getting-started/install-wallet-sdk This snippet demonstrates how to install the Bittensor Wallet SDK using pip from the Python Package Index (PyPI). It includes steps for creating and activating a virtual environment to isolate dependencies, ensuring a clean installation. ```Python python3 -m venv btwallet-venv source btwallet-venv/bin/activate pip install bittensor-wallet ``` -------------------------------- ### Install BTCLI from Source Source: https://docs.learnbittensor.org/getting-started/install-btcli Installs the Bittensor CLI from the local source directory using pip. This command should be run from within the `btcli` repository directory after cloning and activating a virtual environment, completing the source installation process. ```Shell pip3 install . ``` -------------------------------- ### Bittensor CLI Wallet Overview Command Examples Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/overview/index Examples demonstrating how to use the `btcli wallet overview` command from the command line. These examples show basic usage and how to apply options like `--all` for including all wallets and `--sort_by` for custom sorting of the output. ```Bash btcli wallet overview btcli wallet overview --all --sort_by stake --sort_order descending ``` -------------------------------- ### Create Configuration File from Example Source: https://docs.learnbittensor.org/evm-tutorials/evm-testnet-with-metamask-wallet This command copies the `config-example.js` file to `config.js`. This action creates a new, editable configuration file, allowing users to customize settings like the private key without altering the original example template. ```bash cp config-example.js config.js ``` -------------------------------- ### Initialize and Manage FastAPIThreadedServer Source: https://docs.learnbittensor.org/python-api/html/_modules/bittensor/core/axon Demonstrates how to initialize the FastAPI application, configure `uvicorn`, create an instance of `FastAPIThreadedServer`, and control its lifecycle by starting and stopping the server. This example shows the basic setup for integrating FastAPI with the Axon server. ```python self.app = FastAPI() log_level = "trace" self.fast_config = uvicorn.Config(self.app, host="0.0.0.0", port=self.config.axon.port, log_level=log_level) self.fast_server = FastAPIThreadedServer(config=self.fast_config) self.fast_server.start() # do something self.fast_server.stop() ``` -------------------------------- ### Verify BTCLI Installation and Version Source: https://docs.learnbittensor.org/getting-started/install-btcli Checks the installed version of the Bittensor CLI (`btcli`) to confirm successful installation and identify the current version. This command is applicable across all installation methods and is crucial for ensuring you are using the latest release. Example output: `BTCLI version: 9.2.0` ```Shell btcli --version ``` -------------------------------- ### Create Default Bittensor Wallet Source: https://docs.learnbittensor.org/getting-started/install-wallet-sdk Demonstrates how to initialize and create a new `bittensor_wallet` instance with default settings. This process generates both a coldkey and a hotkey, along with their respective mnemonics. ```python from bittensor_wallet import Wallet # creates wallet with name `default` wallet = Wallet() wallet.create() ``` -------------------------------- ### Create Configuration File from Example Source: https://docs.learnbittensor.org/evm-tutorials/evm-localnet-with-metamask-wallet Copies the `config-example.js` file to `config.js`, creating a new editable configuration file. This allows users to customize settings without altering the original example file. ```bash cp config-example.js config.js ``` -------------------------------- ### Bittensor CLI Wallet Overview Command Examples Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/overview Examples demonstrating how to use the `btcli wallet overview` command to display detailed information about registered Bittensor accounts, including options for filtering and sorting. ```Bash btcli wallet overview btcli wallet overview --all --sort_by stake --sort_order descending ``` -------------------------------- ### Example: Get Subnet Hyperparameters using `btcli su get` Source: https://docs.learnbittensor.org/btcli Illustrates how to retrieve all hyperparameters for a specified subnet using the `btcli su get` command, providing a quick way to inspect current configurations. ```Bash btcli sudo get --netuid 1 ``` -------------------------------- ### Starting the Bittensor Axon Server Source: https://docs.learnbittensor.org/python-api/html/autoapi/bittensor/core/axon/index This Python example illustrates how to start the Axon's internal server, enabling it to accept and process incoming network requests. The `start` method transitions the Axon to an active state, making it a functional participant in the Bittensor network. ```Python my_axon = bittensor.Axon(...) ... # setup axon, attach functions, etc. my_axon.start() # Starts the axon server ``` -------------------------------- ### Navigate to Examples Directory Source: https://docs.learnbittensor.org/evm-tutorials/evm-testnet-with-metamask-wallet This command changes the current working directory to the `examples` subdirectory within the EVM-Bittensor repository. This step is essential before creating or modifying configuration files specific to the tutorials. ```bash cd examples ``` -------------------------------- ### Example: Get child hotkeys for a specific subnet Source: https://docs.learnbittensor.org/btcli Illustrates how to retrieve child hotkey information for a single specified subnet using the `btcli stake child get` command. ```shell btcli stake child get --netuid 1 ``` -------------------------------- ### Set Up Miner Wallet Coldkey and Hotkey Source: https://docs.learnbittensor.org/local-build/provision-wallets These commands set up a complete wallet for a miner, including both a coldkey and a hotkey. The coldkey secures the miner's assets, while the hotkey is used for operational activities like signing transactions and participating in subnet operations. ```Shell btcli wallet new_coldkey \ --wallet.name miner ``` ```Shell btcli wallet new_hotkey \ --wallet.name miner \ --wallet.hotkey default ``` -------------------------------- ### Example: Get child hotkeys for all subnets Source: https://docs.learnbittensor.org/btcli Shows how to retrieve child hotkey information across all available subnets using the `btcli stake child get` command with the `--all-netuids` flag. ```shell btcli stake child get --all-netuids ``` -------------------------------- ### Clone Bittensor GitHub Repository Source: https://docs.learnbittensor.org/getting-started/installation Clones the official Bittensor source code repository from GitHub to the local machine, which is the first step for installing the SDK from source. ```bash git clone https://github.com/opentensor/bittensor.git ``` -------------------------------- ### Example: Starting a Bittensor Axon Server Source: https://docs.learnbittensor.org/python-api/html/autoapi/bittensor/core/axon Illustrates the process of starting the Bittensor Axon's internal server and its FastAPI thread, making it operational and ready to accept and process incoming network requests. ```python my_axon = bittensor.Axon(...) ... # setup axon, attach functions, etc. my_axon.start() ``` -------------------------------- ### Install EVM-Bittensor Project Dependencies Source: https://docs.learnbittensor.org/evm-tutorials/install This sequence of shell commands outlines the complete process for setting up the EVM-Bittensor project. It begins by cloning the official repository, then changes the current directory to the newly cloned project, and finally installs all project dependencies using Yarn. These steps are crucial for preparing the environment to run any EVM tutorials. ```Shell git clone https://github.com/opentensor/evm-bittensor.git ``` ```Shell cd evm-bittensor ``` ```Shell yarn install ``` -------------------------------- ### Create Bittensor Wallet with Custom Parameters Source: https://docs.learnbittensor.org/getting-started/install-wallet-sdk Illustrates how to create a `bittensor_wallet` instance by specifying custom `name`, `path`, and `hotkey` arguments during initialization. This allows for greater control over wallet identification and storage location. ```python from bittensor_wallet import Wallet my_name = "my_wallet_name" my_path = "path_to_my_wallet" my_hotkey = "name_of_my_hotkey" my_wallet = Wallet(name=my_name, path=my_path, hotkey=my_hotkey) my_wallet.create() ``` -------------------------------- ### Bittensor CLI Get Children Example Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/stake Example command-line interface usage for retrieving child hotkey information on a specific Bittensor subnet. This command will display a table of child hotkeys, their parent, stake proportion, and expiration. ```bash btcli stake get_children --netuid 1 ``` -------------------------------- ### Navigate to Bittensor Repository Directory Source: https://docs.learnbittensor.org/getting-started/installation Changes the current working directory to the newly cloned Bittensor repository, preparing for local installation steps. ```bash cd bittensor ``` -------------------------------- ### Configure and Start Bittensor Axon with Custom Functions Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/axon/index This Python snippet demonstrates a fragment of configuring and starting a Bittensor Axon instance. It shows how custom functions for blacklisting and prioritizing incoming requests (`blacklist_fn`, `priority_fn`) are passed during Axon setup, followed by the `serve()` and `start()` methods to initiate the Axon's operation on the network. ```python blacklist_fn = blacklist_my_synapse_2, priority_fn = prioritize_my_synape_2 ).serve( netuid = ... subtensor = ... ).start() ``` -------------------------------- ### Example Usage of FastAPIThreadedServer in Bittensor Source: https://docs.learnbittensor.org/python-api/html/autoapi/bittensor/core/axon Illustrates the typical workflow for initializing, configuring, starting, and gracefully stopping the `FastAPIThreadedServer` within a Bittensor application. This example demonstrates how to integrate a FastAPI instance with Uvicorn configuration and manage its lifecycle. ```Python self.app = FastAPI() log_level = "trace" self.fast_config = uvicorn.Config(self.app, host="0.0.0.0", port=self.config.axon.port, log_level=log_level) self.fast_server = FastAPIThreadedServer(config=self.fast_config) self.fast_server.start() # do something self.fast_server.stop() ``` -------------------------------- ### Bittensor CLI Example: Get Children Hotkey Info Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/index Example command-line usage for retrieving information about child hotkeys on a Bittensor subnet. This command displays a table with child hotkey details, including parent, proportion, and expiration. ```Bash btcli stake get_children --netuid 1 ``` -------------------------------- ### Access Bittensor CLI Configuration Help Source: https://docs.learnbittensor.org/getting-started/install-btcli This command displays detailed help information for the `btcli config` command, providing insights into available configuration options and their usage. ```bash btcli config --help ``` -------------------------------- ### Navigate to Examples Directory Source: https://docs.learnbittensor.org/evm-tutorials/evm-localnet-with-metamask-wallet Changes the current working directory to the 'examples' subdirectory within the EVM-Bittensor repository. This step is essential for accessing and modifying the project's configuration files. ```bash cd examples ``` -------------------------------- ### Python Example for Bittensor Axon attach() Method Source: https://docs.learnbittensor.org/python-api/html/autoapi/bittensor/core/axon Provides a practical Python example demonstrating how to define and integrate custom `forward_fn`, `blacklist_fn`, `priority_fn`, and `verify_fn` functions with a `bittensor.Axon` instance. This snippet showcases the setup for custom request processing and verification logic. ```python def forward_custom(synapse: MyCustomSynapse) -> MyCustomSynapse: # Custom logic for processing the request return synapse def blacklist_custom(synapse: MyCustomSynapse) -> tuple[bool, str]: return True, "Allowed!" def priority_custom(synapse: MyCustomSynapse) -> float: return 1.0 def verify_custom(synapse: MyCustomSynapse): # Custom logic for verifying the request pass my_axon = bittensor.Axon(...) my_axon.attach(forward_fn=forward_custom, verify_fn=verify_custom) ``` -------------------------------- ### Verify Local Bittensor Subtensor Setup by Listing Subnets Source: https://docs.learnbittensor.org/local-build/deploy This command uses the `btcli` tool to connect to a locally running Bittensor blockchain instance and list its available subnets. Executing this command helps confirm that the local blockchain is operational and accessible, providing immediate feedback on the setup's success. ```Shell btcli subnet list --network ws://127.0.0.1:9944 ``` -------------------------------- ### Example Usage: Get Children Hotkeys with Bittensor CLI Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/stake/index This command-line example demonstrates how to use the `btcli` tool to retrieve information about child hotkeys on a specific Bittensor subnet. The `--netuid` flag specifies the unique identifier of the network subnet. ```bash btcli stake get_children --netuid 1 ``` -------------------------------- ### Navigate to BTCLI Directory Source: https://docs.learnbittensor.org/getting-started/install-btcli Changes the current working directory to the newly cloned `btcli` repository. This step is crucial to ensure that subsequent installation commands are executed within the correct project context. ```Shell cd btcli ``` -------------------------------- ### Bittensor AutocompleteCommand API Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/index API reference for the `AutocompleteCommand` class, designed to guide users on installing and running autocompletion for the Bittensor CLI. ```APIDOC class bittensor.commands.AutocompleteCommand static run(cli) static add_args(parser) static check_config(config) ``` -------------------------------- ### Install Bittensor SDK from Source Source: https://docs.learnbittensor.org/dynamic-tao/sdk-cheat-sheet Steps to install the Bittensor SDK by cloning the repository from GitHub, checking out the specific 'rao' branch, and performing a local installation. ```bash git clone https://github.com/opentensor/bittensor git checkout rao pip install . ``` -------------------------------- ### Example: Stopping a Bittensor Axon Server Source: https://docs.learnbittensor.org/python-api/html/autoapi/bittensor/core/axon/index Demonstrates how to initialize, start, and then stop a `bittensor.Axon` instance, effectively ceasing its ability to accept new network requests and gracefully terminating connections. ```Python my_axon = bittensor.Axon(...) my_axon.start() ... my_axon.stop() # Stops the axon server ``` -------------------------------- ### Create EVM-Bittensor Configuration File Source: https://docs.learnbittensor.org/evm-tutorials/evm-mainnet-with-metamask-wallet This command copies the `config-example.js` file to `config.js`. This creates a new configuration file that can be customized with sensitive information like private keys, while preserving the original example file. ```bash cp config-example.js config.js ``` -------------------------------- ### Example Bittensor Subnet Hyperparameter Values Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/network/index An illustrative output showing typical hyperparameter values for a Bittensor subnet. This data is retrieved using commands like `btcli sudo get --netuid`. ```Text registration_allowed True target_regs_per_interval 2 min_burn 1000000000 max_burn 100000000000 bonds_moving_avg 900000 max_regs_per_block 1 ``` -------------------------------- ### Bittensor Wallet Overview Command API Reference Source: https://docs.learnbittensor.org/legacy-python-api/html/_modules/bittensor/commands/overview Detailed API documentation for the `OverviewCommand` class, outlining its purpose, the structure of its output, and the functionality of its static methods for managing and monitoring Bittensor accounts. ```APIDOC class OverviewCommand: Executes the `overview` command to present a detailed overview of the user's registered accounts on the Bittensor network. This command compiles and displays comprehensive information about each neuron associated with the user's wallets, including both hotkeys and coldkeys. It is especially useful for users managing multiple accounts or seeking a summary of their network activities and stake distributions. Usage: The command offers various options to customize the output. Users can filter the displayed data by specific netuids, sort by different criteria, and choose to include all wallets in the user's configuration directory. The output is presented in a tabular format with the following columns: - COLDKEY: The SS58 address of the coldkey. - HOTKEY: The SS58 address of the hotkey. - UID: Unique identifier of the neuron. - ACTIVE: Indicates if the neuron is active. - STAKE(τ): Amount of stake in the neuron, in Tao. - RANK: The rank of the neuron within the network. - TRUST: Trust score of the neuron. - CONSENSUS: Consensus score of the neuron. - INCENTIVE: Incentive score of the neuron. - DIVIDENDS: Dividends earned by the neuron. - EMISSION(p): Emission received by the neuron, in Rho. - VTRUST: Validator trust score of the neuron. - VPERMIT: Indicates if the neuron has a validator permit. - UPDATED: Time since last update. - AXON: IP address and port of the neuron. - HOTKEY_SS58: Human-readable representation of the hotkey. Note: This command is read-only and does not modify the network state or account configurations. It provides a quick and comprehensive view of the user's network presence, making it ideal for monitoring account status, stake distribution, and overall contribution to the Bittensor network. Methods: run(cli: "bittensor.cli") -> None Prints an overview for the wallet's coldkey. Parameters: cli (bittensor.cli): The Bittensor CLI instance. Returns ``` -------------------------------- ### Bittensor Subnet Get Hyperparams Command API and CLI Usage Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/commands/network/index Comprehensive documentation for the `SubnetGetHyperparamsCommand` class, including its API methods and a practical command-line example demonstrating how to retrieve subnet hyperparameters using `btcli`. ```APIDOC *class* bittensor.commands.network.SubnetGetHyperparamsCommand: Executes the `get` command to retrieve the hyperparameters of a specific subnet on the Bittensor network. This command is similar to the `hyperparameters` command but may be used in different contexts within the CLI. Usage: The command connects to the Bittensor network, queries the specified subnet, and returns a detailed list of all its hyperparameters. This includes crucial operational parameters that determine the subnet’s performance and interaction within the network. *static* run(*cli*): View hyperparameters of a subnetwork. Parameters: cli (bittensor.cli) *static* _run(*cli*, *subtensor*): View hyperparameters of a subnetwork. Parameters: cli (bittensor.cli) subtensor (bittensor.subtensor) *static* check_config(*config*): Parameters: config (bittensor.config) ``` ```Shell $ btcli sudo get --netuid 1 Subnet Hyperparameters - NETUID: 1 - finney HYPERPARAMETER VALUE rho 10 kappa 32767 immunity_period 7200 min_allowed_weights 8 max_weight_limit 455 tempo 99 min_difficulty 1000000000000000000 max_difficulty 1000000000000000000 weights_version 2013 weights_rate_limit 100 adjustment_interval 112 activity_cutoff 5000 registration_allowed True target_regs_per_interval 2 min_burn 1000000000 max_burn 100000000000 bonds_moving_avg 900000 max_regs_per_block 1 ``` -------------------------------- ### Bittensor Axon Serving Method Source: https://docs.learnbittensor.org/legacy-python-api/html/autoapi/bittensor/axon/index Documents the `serve` method of the `bittensor.axon` class, which integrates the Axon into the Bittensor network, allowing it to start receiving and processing requests from other neurons. It details parameters like `netuid` and `subtensor` and provides a Python example for its usage. ```APIDOC bittensor.axon.serve(netuid: int, subtensor: bittensor.subtensor, optional) - Integrates the Axon into the Bittensor network. - Parameters: - netuid (int): The unique identifier of the subnet to register on. Essential for Axon positioning. - subtensor (bittensor.subtensor, optional): The subtensor connection to use for serving. If not provided, a new connection is established based on default configurations. - Returns: - bittensor.axon: The Axon instance that is now actively serving on the specified subtensor. - Note: - The `serve` method is crucial for integrating the Axon into the Bittensor network, allowing it to start receiving and processing requests from other neurons. ``` ```python my_axon = bittensor.axon(...) subtensor = bt.subtensor(network="local") # Local by default my_axon.serve(netuid=1, subtensor=subtensor) # Serves the axon on subnet with netuid 1 ``` -------------------------------- ### Standard Ethereum Precompiles on Bittensor EVM Source: https://docs.learnbittensor.org/evm-tutorials/examples Documentation for standard Ethereum precompiled smart contracts available on the Bittensor EVM, detailing their addresses, functions, and purposes. ```APIDOC ECRecover (0x1): Recover the address associated with the public key from elliptic curve signature Sha256 (0x2): SHA-256 hash function Ripemd160 (0x3): RIPEMD-160 hash function Identity (0x4): Identity function (returns input data) Modexp (0x5): Modular exponentiation Sha3FIPS256 (0x400): SHA3-256 hash function (FIPS variant) ECRecoverPublicKey (0x401): Recover the public key from an elliptic curve signature ```