Subnet Precompile
This precompile allows you to interact with Bittensor subnets through EVM smart contracts, affording functionality for registering networks, viewing and setting network parameters, and querying network state.
This page:
- described the precompile's available functions on the precompile
- demonstrates the precompile's usage with example scripts.
The subnet precompile is available at address 0x803 (2051 in decimal).
View the source on GitHub
Subnet operations have distinct requirements!
-
Creating a subnet, i.e.
registerNetwork, requires a coldkey with sufficient TAO to cover the current burn cost. -
Setting subnet hyperparameters requires the private key for the coldkey that owns the subnet (the one that created it, unless this has been transferred).
Available Functions
The subnet precompile provides comprehensive functionality for subnet management and configuration. All functions are categorized below:
Network Registration
registerNetwork
Create/register a new subnet, without setting identity information.
Parameters:
hotkey(bytes32): The hotkey (32 bytes) that will own the network
Returns:
- None (payable function)
Description: Registers a new subnet on the Bittensor network. The caller becomes the subnet owner and can manage subnet parameters.
registerNetworkWithIdentity
Registers a new subnet with detailed identity information.
Parameters:
hotkey(bytes32): The hotkey that will own the networksubnetName(string): Name of the subnet (max 256 chars)githubRepo(string): GitHub repository URL (max 1024 chars)subnetContact(string): Contact information (max 1024 chars)subnetUrl(string): Subnet website URL (max 1024 chars)discord(string): Discord server invite (max 256 chars)description(string): Subnet description (max 1024 chars)additional(string): Additional information (max 1024 chars)
Returns:
- None (payable function)
Description: Registers a new subnet with comprehensive identity metadata that helps users understand the subnet's purpose and how to interact with it.
Rate Limiting
getServingRateLimit
Gets the serving rate limit for a subnet.
Parameters:
netuid(uint16): The subnetwork ID
Returns:
uint64: The serving rate limit value
setServingRateLimit
Sets the serving rate limit for a subnet.
Parameters:
netuid(uint16): The subnetwork IDservingRateLimit(uint64): The new serving rate limit value
Returns:
- None (payable function)
Difficulty Management
getMinDifficulty
Gets the minimum difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork ID
Returns:
uint64: The minimum difficulty value
setMinDifficulty
Sets the minimum difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork IDminDifficulty(uint64): The new minimum difficulty value
Returns:
- None (payable function)
getMaxDifficulty
Gets the maximum difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork ID
Returns:
uint64: The maximum difficulty value
setMaxDifficulty
Sets the maximum difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork IDmaxDifficulty(uint64): The new maximum difficulty value
Returns:
- None (payable function)
getDifficulty
Gets the current difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork ID
Returns:
uint64: The current difficulty value
setDifficulty
Sets the current difficulty for a subnet.
Parameters:
netuid(uint16): The subnetwork IDdifficulty(uint64): The new difficulty value
Returns:
- None (payable function)
Weight Management
getWeightsVersionKey
Gets the weights version key for a subnet.
Parameters:
netuid(uint16): The subnetwork ID
Returns:
uint64: The weights version key value
setWeightsVersionKey
Sets the weights version key for a subnet.
Parameters:
netuid(uint16): The subnetwork IDweightsVersionKey(uint64): The new weights version key value
Returns:
- None (payable function)