bittensor


Namebittensor JSON
Version 6.12.0 PyPI version JSON
download
home_pagehttps://github.com/opentensor/bittensor
Summarybittensor
upload_time2024-05-02 22:32:11
maintainerNone
docs_urlNone
authorbittensor.com
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <div align="center">

# **Bittensor** <!-- omit in toc -->
[![Discord Chat](https://img.shields.io/discord/308323056592486420.svg)](https://discord.gg/bittensor)
[![PyPI version](https://badge.fury.io/py/bittensor.svg)](https://badge.fury.io/py/bittensor)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 

---

### Internet-scale Neural Networks <!-- omit in toc -->

[Discord](https://discord.gg/qasY3HA9F9) • [Network](https://taostats.io/) • [Research](https://bittensor.com/whitepaper)

</div>

Bittensor is a mining network, similar to Bitcoin, that includes built-in incentives designed to encourage computers to provide access to machine learning models in an efficient and censorship-resistant manner. These models can be queried by users seeking outputs from the network, for instance; generating text, audio, and images, or for extracting numerical representations of these input types. Under the hood, Bittensor’s *economic market*, is facilitated by a blockchain token mechanism, through which producers (***miners***) and the verification of the work done by those miners (***validators***) are rewarded. Miners host, train or otherwise procure machine learning systems into the network as a means of fulfilling the verification problems defined by the validators, like the ability to generate responses from prompts i.e. “What is the capital of Texas?. 

The token based mechanism under which the miners are incentivized ensures that they are constantly driven to make their knowledge output more useful, in terms of speed, intelligence and diversity. The value generated by the network is distributed directly to the individuals producing that value, without intermediaries. Anyone can participate in this endeavour, extract value from the network, and govern Bittensor. The network is open to all participants, and no individual or group has full control over what is learned, who can profit from it, or who can access it.

To learn more about Bittensor, please read our [paper](https://bittensor.com/whitepaper).

# Install
There are three ways to install Bittensor

1. Through the installer:
```bash
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh)"
```
2. With pip:
```bash
$ pip3 install bittensor
```
3. From source:
```bash
$ git clone https://github.com/opentensor/bittensor.git
$ python3 -m pip install -e bittensor/
```
4. Using Conda (recommended for **Apple M1**):
```bash
$ conda env create -f ~/.bittensor/bittensor/scripts/environments/apple_m1_environment.yml
$ conda activate bittensor
```

To test your installation, type:
```bash
$ btcli --help
```
or using python
```python
import bittensor
```

#### CUDA
If you anticipate using PoW registration for subnets or the faucet (only available on staging), please install `cubit` as well for your version of python. You can find the Opentensor cubit implementation and instructions [here](https://github.com/opentensor/cubit).

For example with python 3.10:
```bash
pip install https://github.com/opentensor/cubit/releases/download/v1.1.2/cubit-1.1.2-cp310-cp310-linux_x86_64.whl
```

# Wallets 

Wallets are the core ownership and identity technology around which all functions on Bittensor are carried out. Bittensor wallets consists of a coldkey and hotkey where the coldkey may contain many hotkeys, while each hotkey can only belong to a single coldkey. Coldkeys store funds securely, and operate functions such as transfers and staking, while hotkeys are used for all online operations such as signing queries, running miners and validating. 

Wallets can be created in two ways.
1. Using the python-api
```python
import bittensor
wallet = bittensor.wallet()
wallet.create_new_coldkey()
wallet.create_new_hotkey()
print (wallet)
"Wallet (default, default, ~/.bittensor/wallets/)"
```
2. Or using btcli
> Use the subcommand `wallet` or it's alias `w`:
```bash
$ btcli wallet new_coldkey
    Enter wallet name (default):      

    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 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 post maid erode shy captain verify scan shoulder brisk mountain pelican elbow

$ btcli wallet new_hotkey
    Enter wallet name (default): d1
    Enter hotkey name (default): 

    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 total steak hour bird hedgehog trim timber can friend dry worry text
```
In both cases you should be able to view your keys by navigating to ~/.bittensor/wallets or viewed by running ```btcli wallet list```
```bash
$ tree ~/.bittensor/
    .bittensor/                 # Bittensor, root directory.
        wallets/                # The folder containing all bittensor wallets.
            default/            # The name of your wallet, "default"
                coldkey         # You encrypted coldkey.
                coldkeypub.txt  # Your coldkey public address
                hotkeys/        # The folder containing all of your hotkeys.
                    default     # You unencrypted hotkey information.
```
Your default wallet ```Wallet (default, default, ~/.bittensor/wallets/)``` is always used unless you specify otherwise. Be sure to store your mnemonics safely. If you lose your password to your wallet, or the access to the machine where the wallet is stored, you can always regenerate the coldkey using the mnemonic you saved from above. 
```bash
$ btcli wallet regen_coldkey --mnemonic **** *** **** **** ***** **** *** **** **** **** ***** *****
```

## Using the cli
The Bittensor command line interface (`btcli`) is the primary command line tool for interacting with the Bittensor network. It can be used to deploy nodes, manage wallets, stake/unstake, nominate, transfer tokens, and more.

### Basic Usage

To get the list of all the available commands and their descriptions, you can use:

```bash
btcli --help

usage: btcli <command> <command args>

bittensor cli v{bittensor.__version__}

commands:
  subnets (s, subnet) - Commands for managing and viewing subnetworks.
  root (r, roots) - Commands for managing and viewing the root network.
  wallet (w, wallets) - Commands for managing and viewing wallets.
  stake (st, stakes) - Commands for staking and removing stake from hotkey accounts.
  sudo (su, sudos) - Commands for subnet management.
  legacy (l) - Miscellaneous commands.
```

### Example Commands

#### Viewing Senate Proposals
```bash
btcli root proposals
```

#### Viewing Senate Members
```bash
btcli root list_delegates
```

#### Viewing Proposal Votes
```bash
btcli root senate_vote --proposal=[PROPOSAL_HASH]
```

#### Registering for Senate
```bash
btcli root register
```

#### Leaving Senate
```bash
btcli root undelegate
```

#### Voting in Senate
```bash
btcli root senate_vote --proposal=[PROPOSAL_HASH]
```

#### Miscellaneous Commands
```bash
btcli legacy update
btcli legacy faucet
```

#### Managing Subnets
```bash
btcli subnets list
btcli subnets create
```

#### Managing Wallets
```bash
btcli wallet list
btcli wallet transfer
```

### Note

Please replace the subcommands and arguments as necessary to suit your needs, and always refer to `btcli --help` or `btcli <command> --help` for the most up-to-date and accurate information.

For example:
```bash
btcli subnets --help

usage: btcli <command> <command args> subnets [-h] {list,metagraph,lock_cost,create,register,pow_register,hyperparameters} ...

positional arguments:
  {list,metagraph,lock_cost,create,register,pow_register,hyperparameters}
                        Commands for managing and viewing subnetworks.
    list                List all subnets on the network.
    metagraph           View a subnet metagraph information.
    lock_cost           Return the lock cost to register a subnet.
    create              Create a new bittensor subnetwork on this chain.
    register            Register a wallet to a network.
    pow_register        Register a wallet to a network using PoW.
    hyperparameters     View subnet hyperparameters.

options:
  -h, --help            show this help message and exit
```

### Post-Installation Steps

To enable autocompletion for Bittensor CLI, run the following commands:

```bash
btcli --print-completion bash >> ~/.bashrc  # For Bash
btcli --print-completion zsh >> ~/.zshrc    # For Zsh
source ~/.bashrc  # Reload Bash configuration to take effect
```

# The Bittensor Package
The bittensor package contains data structures for interacting with the bittensor ecosystem, writing miners, validators and querying the network. Additionally, it provides many utilities for efficient serialization of Tensors over the wire, performing data analysis of the network, and other useful utilities.

Wallet: Interface over locally stored bittensor hot + coldkey styled wallets. 
```python
import bittensor
# Bittensor's wallet maintenance class.
wallet = bittensor.wallet() 
# Access the hotkey
wallet.hotkey 
# Access the coldkey
wallet.coldkey ( requires decryption )
# Sign data with the keypair.
wallet.coldkey.sign( data )

```

Subtensor: Interfaces with bittensor's blockchain and can perform operations like extracting state information or sending transactions.
```python
import bittensor
# Bittensor's chain interface.
subtensor = bittensor.subtensor() 
# Get the chain block
subtensor.get_current_block()
# Transfer Tao to a destination address.
subtensor.transfer( wallet = wallet, dest = "xxxxxxx..xxxxx", amount = 10.0)
# Register a wallet onto a subnetwork
subtensor.register( wallet = wallet, netuid = 1 )
```

Metagraph: Encapsulates the chain state of a particular subnetwork at a specific block.
```python
import bittensor
# Bittensor's chain state object.
metagraph = bittensor.metagraph( netuid = 1 ) 
# Resync the graph with the most recent chain state
metagraph.sync()
# Get the list of stake values
print ( metagraph.S )
# Get endpoint information for the entire subnetwork
print ( metagraph.axons )
# Get the hotkey information for the miner in the 10th slot
print ( metagraph.hotkeys[ 10 ] )
# Sync the metagraph at another block
metagraph.sync( block = 100000 )
# Save the metagraph
metagraph.save()
# Load the same
metagraph.load()
```

Synapse: Responsible for defining the protocol definition between axon servers and dendrite clients
```python
class Topk( bittensor.Synapse ):
    topk: int = 2  # Number of "top" elements to select
    input: bittensor.Tensor = pydantic.Field(..., allow_mutation=False)  # Ensure that input cannot be set on the server side. 
    v: bittensor.Tensor = None
    i: bittensor.Tensor = None

def topk( synapse: Topk ) -> Topk:
    v, i = torch.topk( synapse.input.deserialize(), k = synapse.topk ) 
    synapse.v = bittensor.Tensor.serialize( v )
    synapse.i = bittensor.Tensor.serialize( i )
    return synapse

# Attach the forward function to the axon and start.
axon = bittensor.axon().attach( topk ).start()
```

Axon: Serves Synapse protocols with custom blacklist, priority and verify functions.

```python
import bittensor

class MySynapse( bittensor.Synapse ):
    input: int = 1
    output: int = None

# Define a custom request forwarding function
def forward( synapse: MySynapse ) -> MySynapse:
    # Apply custom logic to synapse and return it
    synapse.output = 2
    return synapse

# Define a custom request verification function
def verify_my_synapse( synapse: MySynapse ):
    # Apply custom verification logic to synapse
    # Optionally raise Exception

# Define a custom request blacklist function
def blacklist_my_synapse( synapse: MySynapse ) -> bool:
    # Apply custom blacklist 
    # return False ( if non blacklisted ) or True ( if blacklisted )

# Define a custom request priority function
def prioritize_my_synape( synapse: MySynapse ) -> float:
    # Apply custom priority
    return 1.0 

# Initialize Axon object with a custom configuration
my_axon = bittensor.axon(config=my_config, wallet=my_wallet, port=9090, ip="192.0.2.0", external_ip="203.0.113.0", external_port=7070)

# Attach the endpoint with the specified verification and forwarding functions  
my_axon.attach(
    forward_fn = forward_my_synapse, 
    verify_fn=verify_my_synapse,
    blacklist_fn = blacklist_my_synapse,
    priority_fn = prioritize_my_synape
).start()
```     

Dendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed 
to send requests to those endpoints to receive inputs.

Example:
```python
dendrite_obj = dendrite( wallet = bittensor.wallet() )
# pings the axon endpoint
await d( <axon> )
# ping multiple axon endpoints
await d( [<axons>] ) 
# Send custom synapse request to axon.
await d( bittensor.axon(), bittensor.Synapse() ) 
# Query all metagraph objects.
await d( meta.axons, bittensor.Synapse() ) 
```

## Setting weights on root network
Use the `root` subcommand to access setting weights on the network across subnets.

```bash
btcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>
Enter netuids (e.g. 0, 1, 2 ...):
# Here enter your selected netuids to set weights on
1, 2

>Enter weights (e.g. 0.09, 0.09, 0.09 ...): 
# These do not need to sum to 1, we do normalization on the backend.
# Values must be > 0
0.5, 10

Normalized weights: 
        tensor([ 0.5000, 10.0000]) -> tensor([0.0476, 0.9524])

Do you want to set the following root weights?:
  weights: tensor([0.0476, 0.9524])
  uids: tensor([1, 2])? [y/n]: 
y

⠏ 📡 Setting root weights on test ...
```

## Bittensor Subnets API

This guide provides instructions on how to extend the Bittensor Subnets API, a powerful interface for interacting with the Bittensor network across subnets. The Bittensor Subnets API facilitates querying across any subnet that has exposed API endpoints to unlock utility of the Bittensor decentralized network.

The Bittensor Subnets API consists of abstract classes and a registry system to dynamically handle API interactions. It allows developers to implement custom logic for storing and retrieving data, while also providing a straightforward way for end users to interact with these functionalities.

### Core Components

- **APIRegistry**: A central registry that manages API handlers. It allows for dynamic retrieval of handlers based on keys.
- **SubnetsAPI (Abstract Base Class)**: Defines the structure for API implementations, including methods for querying the network and processing responses.
- **StoreUserAPI & RetrieveUserAPI**: Concrete implementations of the `SubnetsAPI` for storing and retrieving user data.

### Implementing Custom Subnet APIs

To implement your own subclasses of `bittensor.SubnetsAPI` to integrate an API into your subnet.

1. **Inherit from `SubnetsAPI`**: Your class should inherit from the `SubnetsAPI` abstract base class.

2. **Implement Required Methods**: Implement the `prepare_synapse` and `process_responses` abstract methods with your custom logic.

That's it! For example:

```python
import bittensor

class CustomSubnetAPI(bittensor.SubnetsAPI):
    def __init__(self, wallet: "bittensor.wallet"):
        super().__init__(wallet)
        # Custom initialization here

    def prepare_synapse(self, *args, **kwargs):
        # Custom synapse preparation logic
        pass

    def process_responses(self, responses):
        # Custom response processing logic
        pass
```

## Release
The release manager should follow the instructions of the [RELEASE_GUIDELINES.md](./RELEASE_GUIDELINES.md) document.

## Contributions
Please review the [contributing guide](./contrib/CONTRIBUTING.md) for more information before making a pull request.

## License
The MIT License (MIT)
Copyright © 2021 Yuma Rao

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


## Acknowledgments
**learning-at-home/hivemind**



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opentensor/bittensor",
    "name": "bittensor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "bittensor.com",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/47/dc/459df9beae20389bf31bd04c7837701af6f25ba14410164c7c3317257e03/bittensor-6.12.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n# **Bittensor** <!-- omit in toc -->\n[![Discord Chat](https://img.shields.io/discord/308323056592486420.svg)](https://discord.gg/bittensor)\n[![PyPI version](https://badge.fury.io/py/bittensor.svg)](https://badge.fury.io/py/bittensor)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) \n\n---\n\n### Internet-scale Neural Networks <!-- omit in toc -->\n\n[Discord](https://discord.gg/qasY3HA9F9) \u2022 [Network](https://taostats.io/) \u2022 [Research](https://bittensor.com/whitepaper)\n\n</div>\n\nBittensor is a mining network, similar to Bitcoin, that includes built-in incentives designed to encourage computers to provide access to machine learning models in an efficient and censorship-resistant manner. These models can be queried by users seeking outputs from the network, for instance; generating text, audio, and images, or for extracting numerical representations of these input types. Under the hood, Bittensor\u2019s *economic market*, is facilitated by a blockchain token mechanism, through which producers (***miners***) and the verification of the work done by those miners (***validators***) are rewarded. Miners host, train or otherwise procure machine learning systems into the network as a means of fulfilling the verification problems defined by the validators, like the ability to generate responses from prompts i.e. \u201cWhat is the capital of Texas?. \n\nThe token based mechanism under which the miners are incentivized ensures that they are constantly driven to make their knowledge output more useful, in terms of speed, intelligence and diversity. The value generated by the network is distributed directly to the individuals producing that value, without intermediaries. Anyone can participate in this endeavour, extract value from the network, and govern Bittensor. The network is open to all participants, and no individual or group has full control over what is learned, who can profit from it, or who can access it.\n\nTo learn more about Bittensor, please read our [paper](https://bittensor.com/whitepaper).\n\n# Install\nThere are three ways to install Bittensor\n\n1. Through the installer:\n```bash\n$ /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh)\"\n```\n2. With pip:\n```bash\n$ pip3 install bittensor\n```\n3. From source:\n```bash\n$ git clone https://github.com/opentensor/bittensor.git\n$ python3 -m pip install -e bittensor/\n```\n4. Using Conda (recommended for **Apple M1**):\n```bash\n$ conda env create -f ~/.bittensor/bittensor/scripts/environments/apple_m1_environment.yml\n$ conda activate bittensor\n```\n\nTo test your installation, type:\n```bash\n$ btcli --help\n```\nor using python\n```python\nimport bittensor\n```\n\n#### CUDA\nIf you anticipate using PoW registration for subnets or the faucet (only available on staging), please install `cubit` as well for your version of python. You can find the Opentensor cubit implementation and instructions [here](https://github.com/opentensor/cubit).\n\nFor example with python 3.10:\n```bash\npip install https://github.com/opentensor/cubit/releases/download/v1.1.2/cubit-1.1.2-cp310-cp310-linux_x86_64.whl\n```\n\n# Wallets \n\nWallets are the core ownership and identity technology around which all functions on Bittensor are carried out. Bittensor wallets consists of a coldkey and hotkey where the coldkey may contain many hotkeys, while each hotkey can only belong to a single coldkey. Coldkeys store funds securely, and operate functions such as transfers and staking, while hotkeys are used for all online operations such as signing queries, running miners and validating. \n\nWallets can be created in two ways.\n1. Using the python-api\n```python\nimport bittensor\nwallet = bittensor.wallet()\nwallet.create_new_coldkey()\nwallet.create_new_hotkey()\nprint (wallet)\n\"Wallet (default, default, ~/.bittensor/wallets/)\"\n```\n2. Or using btcli\n> Use the subcommand `wallet` or it's alias `w`:\n```bash\n$ btcli wallet new_coldkey\n    Enter wallet name (default):      \n\n    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. \n    The mnemonic to the new coldkey is:\n    **** *** **** **** ***** **** *** **** **** **** ***** *****\n    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:\n    btcli w regen_coldkey --mnemonic post maid erode shy captain verify scan shoulder brisk mountain pelican elbow\n\n$ btcli wallet new_hotkey\n    Enter wallet name (default): d1\n    Enter hotkey name (default): \n\n    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. \n    The mnemonic to the new hotkey is:\n    **** *** **** **** ***** **** *** **** **** **** ***** *****\n    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:\n    btcli w regen_hotkey --mnemonic total steak hour bird hedgehog trim timber can friend dry worry text\n```\nIn both cases you should be able to view your keys by navigating to ~/.bittensor/wallets or viewed by running ```btcli wallet list```\n```bash\n$ tree ~/.bittensor/\n    .bittensor/                 # Bittensor, root directory.\n        wallets/                # The folder containing all bittensor wallets.\n            default/            # The name of your wallet, \"default\"\n                coldkey         # You encrypted coldkey.\n                coldkeypub.txt  # Your coldkey public address\n                hotkeys/        # The folder containing all of your hotkeys.\n                    default     # You unencrypted hotkey information.\n```\nYour default wallet ```Wallet (default, default, ~/.bittensor/wallets/)``` is always used unless you specify otherwise. Be sure to store your mnemonics safely. If you lose your password to your wallet, or the access to the machine where the wallet is stored, you can always regenerate the coldkey using the mnemonic you saved from above. \n```bash\n$ btcli wallet regen_coldkey --mnemonic **** *** **** **** ***** **** *** **** **** **** ***** *****\n```\n\n## Using the cli\nThe Bittensor command line interface (`btcli`) is the primary command line tool for interacting with the Bittensor network. It can be used to deploy nodes, manage wallets, stake/unstake, nominate, transfer tokens, and more.\n\n### Basic Usage\n\nTo get the list of all the available commands and their descriptions, you can use:\n\n```bash\nbtcli --help\n\nusage: btcli <command> <command args>\n\nbittensor cli v{bittensor.__version__}\n\ncommands:\n  subnets (s, subnet) - Commands for managing and viewing subnetworks.\n  root (r, roots) - Commands for managing and viewing the root network.\n  wallet (w, wallets) - Commands for managing and viewing wallets.\n  stake (st, stakes) - Commands for staking and removing stake from hotkey accounts.\n  sudo (su, sudos) - Commands for subnet management.\n  legacy (l) - Miscellaneous commands.\n```\n\n### Example Commands\n\n#### Viewing Senate Proposals\n```bash\nbtcli root proposals\n```\n\n#### Viewing Senate Members\n```bash\nbtcli root list_delegates\n```\n\n#### Viewing Proposal Votes\n```bash\nbtcli root senate_vote --proposal=[PROPOSAL_HASH]\n```\n\n#### Registering for Senate\n```bash\nbtcli root register\n```\n\n#### Leaving Senate\n```bash\nbtcli root undelegate\n```\n\n#### Voting in Senate\n```bash\nbtcli root senate_vote --proposal=[PROPOSAL_HASH]\n```\n\n#### Miscellaneous Commands\n```bash\nbtcli legacy update\nbtcli legacy faucet\n```\n\n#### Managing Subnets\n```bash\nbtcli subnets list\nbtcli subnets create\n```\n\n#### Managing Wallets\n```bash\nbtcli wallet list\nbtcli wallet transfer\n```\n\n### Note\n\nPlease replace the subcommands and arguments as necessary to suit your needs, and always refer to `btcli --help` or `btcli <command> --help` for the most up-to-date and accurate information.\n\nFor example:\n```bash\nbtcli subnets --help\n\nusage: btcli <command> <command args> subnets [-h] {list,metagraph,lock_cost,create,register,pow_register,hyperparameters} ...\n\npositional arguments:\n  {list,metagraph,lock_cost,create,register,pow_register,hyperparameters}\n                        Commands for managing and viewing subnetworks.\n    list                List all subnets on the network.\n    metagraph           View a subnet metagraph information.\n    lock_cost           Return the lock cost to register a subnet.\n    create              Create a new bittensor subnetwork on this chain.\n    register            Register a wallet to a network.\n    pow_register        Register a wallet to a network using PoW.\n    hyperparameters     View subnet hyperparameters.\n\noptions:\n  -h, --help            show this help message and exit\n```\n\n### Post-Installation Steps\n\nTo enable autocompletion for Bittensor CLI, run the following commands:\n\n```bash\nbtcli --print-completion bash >> ~/.bashrc  # For Bash\nbtcli --print-completion zsh >> ~/.zshrc    # For Zsh\nsource ~/.bashrc  # Reload Bash configuration to take effect\n```\n\n# The Bittensor Package\nThe bittensor package contains data structures for interacting with the bittensor ecosystem, writing miners, validators and querying the network. Additionally, it provides many utilities for efficient serialization of Tensors over the wire, performing data analysis of the network, and other useful utilities.\n\nWallet: Interface over locally stored bittensor hot + coldkey styled wallets. \n```python\nimport bittensor\n# Bittensor's wallet maintenance class.\nwallet = bittensor.wallet() \n# Access the hotkey\nwallet.hotkey \n# Access the coldkey\nwallet.coldkey ( requires decryption )\n# Sign data with the keypair.\nwallet.coldkey.sign( data )\n\n```\n\nSubtensor: Interfaces with bittensor's blockchain and can perform operations like extracting state information or sending transactions.\n```python\nimport bittensor\n# Bittensor's chain interface.\nsubtensor = bittensor.subtensor() \n# Get the chain block\nsubtensor.get_current_block()\n# Transfer Tao to a destination address.\nsubtensor.transfer( wallet = wallet, dest = \"xxxxxxx..xxxxx\", amount = 10.0)\n# Register a wallet onto a subnetwork\nsubtensor.register( wallet = wallet, netuid = 1 )\n```\n\nMetagraph: Encapsulates the chain state of a particular subnetwork at a specific block.\n```python\nimport bittensor\n# Bittensor's chain state object.\nmetagraph = bittensor.metagraph( netuid = 1 ) \n# Resync the graph with the most recent chain state\nmetagraph.sync()\n# Get the list of stake values\nprint ( metagraph.S )\n# Get endpoint information for the entire subnetwork\nprint ( metagraph.axons )\n# Get the hotkey information for the miner in the 10th slot\nprint ( metagraph.hotkeys[ 10 ] )\n# Sync the metagraph at another block\nmetagraph.sync( block = 100000 )\n# Save the metagraph\nmetagraph.save()\n# Load the same\nmetagraph.load()\n```\n\nSynapse: Responsible for defining the protocol definition between axon servers and dendrite clients\n```python\nclass Topk( bittensor.Synapse ):\n    topk: int = 2  # Number of \"top\" elements to select\n    input: bittensor.Tensor = pydantic.Field(..., allow_mutation=False)  # Ensure that input cannot be set on the server side. \n    v: bittensor.Tensor = None\n    i: bittensor.Tensor = None\n\ndef topk( synapse: Topk ) -> Topk:\n    v, i = torch.topk( synapse.input.deserialize(), k = synapse.topk ) \n    synapse.v = bittensor.Tensor.serialize( v )\n    synapse.i = bittensor.Tensor.serialize( i )\n    return synapse\n\n# Attach the forward function to the axon and start.\naxon = bittensor.axon().attach( topk ).start()\n```\n\nAxon: Serves Synapse protocols with custom blacklist, priority and verify functions.\n\n```python\nimport bittensor\n\nclass MySynapse( bittensor.Synapse ):\n    input: int = 1\n    output: int = None\n\n# Define a custom request forwarding function\ndef forward( synapse: MySynapse ) -> MySynapse:\n    # Apply custom logic to synapse and return it\n    synapse.output = 2\n    return synapse\n\n# Define a custom request verification function\ndef verify_my_synapse( synapse: MySynapse ):\n    # Apply custom verification logic to synapse\n    # Optionally raise Exception\n\n# Define a custom request blacklist function\ndef blacklist_my_synapse( synapse: MySynapse ) -> bool:\n    # Apply custom blacklist \n    # return False ( if non blacklisted ) or True ( if blacklisted )\n\n# Define a custom request priority function\ndef prioritize_my_synape( synapse: MySynapse ) -> float:\n    # Apply custom priority\n    return 1.0 \n\n# Initialize Axon object with a custom configuration\nmy_axon = bittensor.axon(config=my_config, wallet=my_wallet, port=9090, ip=\"192.0.2.0\", external_ip=\"203.0.113.0\", external_port=7070)\n\n# Attach the endpoint with the specified verification and forwarding functions  \nmy_axon.attach(\n    forward_fn = forward_my_synapse, \n    verify_fn=verify_my_synapse,\n    blacklist_fn = blacklist_my_synapse,\n    priority_fn = prioritize_my_synape\n).start()\n```     \n\nDendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed \nto send requests to those endpoints to receive inputs.\n\nExample:\n```python\ndendrite_obj = dendrite( wallet = bittensor.wallet() )\n# pings the axon endpoint\nawait d( <axon> )\n# ping multiple axon endpoints\nawait d( [<axons>] ) \n# Send custom synapse request to axon.\nawait d( bittensor.axon(), bittensor.Synapse() ) \n# Query all metagraph objects.\nawait d( meta.axons, bittensor.Synapse() ) \n```\n\n## Setting weights on root network\nUse the `root` subcommand to access setting weights on the network across subnets.\n\n```bash\nbtcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>\nEnter netuids (e.g. 0, 1, 2 ...):\n# Here enter your selected netuids to set weights on\n1, 2\n\n>Enter weights (e.g. 0.09, 0.09, 0.09 ...): \n# These do not need to sum to 1, we do normalization on the backend.\n# Values must be > 0\n0.5, 10\n\nNormalized weights: \n        tensor([ 0.5000, 10.0000]) -> tensor([0.0476, 0.9524])\n\nDo you want to set the following root weights?:\n  weights: tensor([0.0476, 0.9524])\n  uids: tensor([1, 2])? [y/n]: \ny\n\n\u280f \ud83d\udce1 Setting root weights on test ...\n```\n\n## Bittensor Subnets API\n\nThis guide provides instructions on how to extend the Bittensor Subnets API, a powerful interface for interacting with the Bittensor network across subnets. The Bittensor Subnets API facilitates querying across any subnet that has exposed API endpoints to unlock utility of the Bittensor decentralized network.\n\nThe Bittensor Subnets API consists of abstract classes and a registry system to dynamically handle API interactions. It allows developers to implement custom logic for storing and retrieving data, while also providing a straightforward way for end users to interact with these functionalities.\n\n### Core Components\n\n- **APIRegistry**: A central registry that manages API handlers. It allows for dynamic retrieval of handlers based on keys.\n- **SubnetsAPI (Abstract Base Class)**: Defines the structure for API implementations, including methods for querying the network and processing responses.\n- **StoreUserAPI & RetrieveUserAPI**: Concrete implementations of the `SubnetsAPI` for storing and retrieving user data.\n\n### Implementing Custom Subnet APIs\n\nTo implement your own subclasses of `bittensor.SubnetsAPI` to integrate an API into your subnet.\n\n1. **Inherit from `SubnetsAPI`**: Your class should inherit from the `SubnetsAPI` abstract base class.\n\n2. **Implement Required Methods**: Implement the `prepare_synapse` and `process_responses` abstract methods with your custom logic.\n\nThat's it! For example:\n\n```python\nimport bittensor\n\nclass CustomSubnetAPI(bittensor.SubnetsAPI):\n    def __init__(self, wallet: \"bittensor.wallet\"):\n        super().__init__(wallet)\n        # Custom initialization here\n\n    def prepare_synapse(self, *args, **kwargs):\n        # Custom synapse preparation logic\n        pass\n\n    def process_responses(self, responses):\n        # Custom response processing logic\n        pass\n```\n\n## Release\nThe release manager should follow the instructions of the [RELEASE_GUIDELINES.md](./RELEASE_GUIDELINES.md) document.\n\n## Contributions\nPlease review the [contributing guide](./contrib/CONTRIBUTING.md) for more information before making a pull request.\n\n## License\nThe MIT License (MIT)\nCopyright \u00a9 2021 Yuma Rao\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n## Acknowledgments\n**learning-at-home/hivemind**\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "bittensor",
    "version": "6.12.0",
    "project_urls": {
        "Homepage": "https://github.com/opentensor/bittensor"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a1f65e6687442a5530d199b245c921d1d20e83517d3d68155ac78eb20041849",
                "md5": "23ec9535a3f4cfebeb53667e1e74588c",
                "sha256": "bbb34fe336139d20893f29cb1f4a5bca47e4236df5e69d1e6d47c256ce6c7e1f"
            },
            "downloads": -1,
            "filename": "bittensor-6.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "23ec9535a3f4cfebeb53667e1e74588c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 284624,
            "upload_time": "2024-05-02T22:32:09",
            "upload_time_iso_8601": "2024-05-02T22:32:09.241442Z",
            "url": "https://files.pythonhosted.org/packages/9a/1f/65e6687442a5530d199b245c921d1d20e83517d3d68155ac78eb20041849/bittensor-6.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47dc459df9beae20389bf31bd04c7837701af6f25ba14410164c7c3317257e03",
                "md5": "4d99c2f0e7f9e1f1e6dabfdbdc215b9f",
                "sha256": "d5cd42b58d91b3332e40d564c38b222fa4e1e85564d5a7e7d80f8c2330d81ed4"
            },
            "downloads": -1,
            "filename": "bittensor-6.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4d99c2f0e7f9e1f1e6dabfdbdc215b9f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 272670,
            "upload_time": "2024-05-02T22:32:11",
            "upload_time_iso_8601": "2024-05-02T22:32:11.438031Z",
            "url": "https://files.pythonhosted.org/packages/47/dc/459df9beae20389bf31bd04c7837701af6f25ba14410164c7c3317257e03/bittensor-6.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 22:32:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opentensor",
    "github_project": "bittensor",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "circle": true,
    "lcname": "bittensor"
}
        
Elapsed time: 0.27989s