try_associate_hotkey

Call v244 → current #91

Attempts to associate a hotkey with a coldkey .

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: validatorsminersdeveloperswallets

The Big Picture

Hotkeys need to be associated with coldkeys before they can be used for staking and registration. try_associate_hotkey creates this link, but unlike a strict version, it 'tries' - if the association can't happen (already associated, invalid), it fails gracefully rather than reverting the entire transaction. Useful in batches.

Why This Matters

Before you can stake to a hotkey or register it on a subnet, the coldkey-hotkey relationship must exist. This call creates that relationship. The 'try' variant is safe to use when you're not sure of the current state - it won't crash your batch.

Example Scenario

You have a new hotkey and want to associate it with your coldkey. Call try_associate_hotkey(hotkey=new_hotkey). If the hotkey is free, it's now linked to your coldkey. If it's already associated elsewhere, the call fails but doesn't revert other operations in a batch.

Common Questions

Why 'try' instead of a strict associate?
The try version fails gracefully - useful in batches where you want to continue even if one association fails. Strict versions would revert everything.
Can I associate the same hotkey to multiple coldkeys?
No - hotkeys have one owner. Once associated, it belongs to that coldkey until transferred via swap_hotkey or similar operations.
When is association needed?
Usually before registration or staking. Some operations implicitly associate if needed. Check specific call requirements.

Use Cases

  • Link a new hotkey to your coldkey before registration
  • Establish ownership before subnet participation
  • Prepare hotkeys for future use
  • Fail-safe association that doesn't revert on error

From Chain Metadata

Attempts to associate a hotkey with a coldkey.

Input Parameters

#NameTypeDescription
0
hotkey
AccountId Hot wallet address (active operations) (hex -> SS58)

Permissions

Origin
Signed
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • Hotkey not already associated with another coldkey
  • Association allowed by network rules
  • Coldkey is valid

Effects

Storage Modified

Postconditions

  • Hotkey associated with coldkey (if successful)
  • Owner mapping updated

Side Effects

  • May fail if conditions not met (non-fatal)
  • Creates coldkey-hotkey relationship for staking

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Build try_associate_hotkey call
const hotkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";

const call = api.tx[stringCamelCase("SubtensorModule")][stringCamelCase("try_associate_hotkey")](
  hotkey
);

Runtime Info

View Source
Pallet Index
7
Call Index
91
First Version
v244
Current Version
v393