Docs
Supported ChainsBittensorSubstrate APIAuthor Methods

author_rotateKeys - Bittensor RPC Method

Generate new session keys for validator operations on Bittensor. Essential for validator setup and key rotation.

Generate a new set of session keys on Bittensor. This method creates fresh cryptographic keys for validator operations and stores them in the node's keystore. The returned keys must be registered on-chain via session.setKeys.

Use Cases

  • Validator setup - Generate initial session keys for decentralized AI inference, subnet-specific AI models, TAO staking, and cross-subnet AI collaboration
  • Key rotation - Periodically rotate keys for security best practices
  • Recovery - Generate new keys after potential key compromise

Request Parameters

Request

This method accepts no parameters.

Response Body

Response
resultBytes

Concatenated SCALE-encoded public keys for all session key types

Code Examples

Bash
curl https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "author_rotateKeys",
    "params": [],
    "id": 1
  }'
JavaScript
import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

// Generate new session keys
const keys = await api.rpc.author.rotateKeys();
console.log('New session keys:', keys.toHex());

// These keys need to be registered on-chain:
// api.tx.session.setKeys(keys, proof)

await api.disconnect();
Python
import requests

url = 'https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY'
payload = {
    'jsonrpc': '2.0',
    'method': 'author_rotateKeys',
    'params': [],
    'id': 1
}

response = requests.post(url, json=payload)
result = response.json()

if 'result' in result:
    session_keys = result['result']
    print(f'New session keys: {session_keys}')
    print('Register these keys using session.setKeys extrinsic')
else:
    print(f"Error: {result.get('error')}")

Validator Setup Workflow

  1. Generate keys - Call author_rotateKeys on your validator node
  2. Register on-chain - Submit session.setKeys(keys, proof) extrinsic
  3. Wait for session - Keys become active in the next session
  4. Verify - Check session.nextKeys storage

Security Considerations

  • Only call this method on your own validator node
  • Session keys are stored in the node's keystore
  • Rotate keys periodically and after any security incident
  • Never expose this RPC method publicly