Transactions

associate-evm-key

Associate an EVM key with a hotkey on a subnet.

View as Markdown

Links an Ethereum-style (H160) address to the signing hotkey on one subnet, letting EVM-side activity be attributed to that neuron. Signed by the hotkey, and additionally proven by the EVM key itself: signature must be an EIP-191 personal-sign signature by the EVM key over the message hotkey_pubkey (32 bytes) ++ keccak_256(scale(block_number)), where the block number is SCALE-encoded (u64 little-endian). Use bittensor.evm.transactions.association_proof to produce it (it needs the EVM private key); a wrong message, block number, or key makes the chain reject the call. Prerequisites: the hotkey must be registered on netuid (else HotKeyNotRegisteredInSubNet) and have an owning coldkey, and re-association is rate-limited to once per 7,200 blocks (~1 day) per neuron.

SignerOriginPalletWraps
hotkeysigned account (pallet role may apply)SubtensorModuleSubtensorModule.associate_evm_key

Parameters

ParameterTypeRequiredDescription
netuidintegeryesSubnet on which the EVM key association is recorded.
evm_keystringyesEVM address to link to the hotkey, as 0x-prefixed H160 hex.
block_numberintegeryesBlock number the signature was produced for; part of the signed message.
signaturestringyesThe EVM key's ownership proof, as 0x-prefixed hex: an EIP-191 personal-sign signature over the hotkey public key concatenated with keccak_256 of the SCALE-encoded block number.

Address parameters (--hotkey, --coldkey, --dest, ...) accept a raw ss58 address, an address-book or proxy-book name, or a local wallet/hotkey name.

CLI

Preview with --dry-run (shows fee, effects, and policy result without submitting), then submit:

btcli tx associate-evm-key \
  --netuid <int> \
  --evm-key <value> \
  --block-number <int> \
  --signature <value> --dry-run
btcli tx associate-evm-key \
  --netuid <int> \
  --evm-key <value> \
  --block-number <int> \
  --signature <value> -w my_coldkey

Python

import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.AssociateEvmKey(netuid=1, evm_key="...", block_number=0, signature="...")

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)

(bt.Subtensor is also the async client — async with bt.Subtensor() as client: — see The client.) Or build the intent by op name, as an agent would:

result = sub.execute_tool("associate_evm_key", {...}, wallet)

On-chain implementation

SubtensorModule.associate_evm_keypallets/subtensor/src/macros/dispatches.rs#L1579:

#[pallet::call_index(93)]
#[pallet::weight((
    <T as crate::pallet::Config>::WeightInfo::associate_evm_key(),
    DispatchClass::Normal,
    Pays::No
))]
pub fn associate_evm_key(
    origin: OriginFor<T>,
    netuid: NetUid,
    evm_key: H160,
    block_number: u64,
    signature: Signature,
) -> DispatchResult {
    Self::do_associate_evm_key(origin, netuid, evm_key, block_number, signature)
}

Delegates to do_associate_evm_key.

Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).