author_rotateKeys
Generate a new set of session keys on Astar. 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 cross-chain DeFi, multi-VM smart contracts, and XCM-enabled interoperability with Ethereum and Cosmos
- Key rotation - Periodically rotate keys for security best practices
- Recovery - Generate new keys after potential key compromise
Parameters#
This method takes no parameters.
Returns#
| Field | Type | Description |
|---|---|---|
result | Bytes | Concatenated SCALE-encoded public keys for all session key types |
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "author_rotateKeys",
"params": [],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-astar.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();
import requests
url = 'https://api-astar.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#
- Generate keys - Call
author_rotateKeyson your validator node - Register on-chain - Submit
session.setKeys(keys, proof)extrinsic - Wait for session - Keys become active in the next session
- Verify - Check
session.nextKeysstorage
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
Related Methods#
author_submitExtrinsic- Submit setKeys transactionauthor_pendingExtrinsics- View pending transactions