state_getStorage
Returns a storage entry at a specific key on Bittensor.
Why Bittensor? Build on the decentralized AI network with $3.9B+ market cap powering 80+ AI subnets with Yuma Consensus for AI model evaluation, subnet-based specialization, dual Substrate+EVM support, and incentivized AI compute marketplace.
Use Cases#
- State queries - Read on-chain storage values
- Account balances - Query account data for decentralized AI inference, subnet-specific AI models, TAO staking, and cross-subnet AI collaboration
- Pallet storage - Access runtime storage items
- Historical state - Query state at specific blocks
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
key | String | Yes | Storage key (hex-encoded) |
blockHash | String | No | Block hash for historical query |
Request#
{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [""],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_getStorage",
"params": [""],
"id": 1
}'
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 });
// Query account balance
const account = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const accountInfo = await api.query.system.account(account);
console.log('Free balance:', accountInfo.data.free.toString());
// Query at specific block
const blockHash = '0x2f0555cc76fc2840a25a6f3a0f0e6d0b1a6dd2e0cecc9e4c2e9e6f3a8d2e5c1b';
const historicalBalance = await api.query.system.account.at(blockHash, account);
console.log('Historical balance:', historicalBalance.data.free.toString());
await api.disconnect();
import requests
def get_storage(key, block_hash=None):
url = 'https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY'
params = [key] if block_hash is None else [key, block_hash]
payload = {
'jsonrpc': '2.0',
'method': 'state_getStorage',
'params': params,
'id': 1
}
response = requests.post(url, json=payload)
return response.json()['result']
# Query :code storage (runtime wasm)
storage_key = ''
value = get_storage(storage_key)
print(f'Storage value: {value[:66]}...' if value else 'None')
Related Methods#
state_getMetadata- Get runtime metadatastate_getKeysPaged- Enumerate storage keys