state_call - Kusama

Calls a runtime API entry point with SCALE-encoded arguments at a block and returns the SCALE-encoded result. Underlies higher-level queries such as fee estimation and account info.

Available over both the JSON-RPC (HTTP) and WebSocket interfaces.

Parameters

ParameterTypeRequiredDescription
namestringYesRuntime API method, e.g. AccountNonceApi_account_nonce
bytesstringYesHex-encoded SCALE arguments
atstringOptionalBlock hash; omit for latest

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "state_call",
    "params": [
    "AccountNonceApi_account_nonce",
    "0x0000000000000000000000000000000000000000000000000000000000000000"
]
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    id: 'getblock.io',
    method: 'state_call',
    params: [
    "AccountNonceApi_account_nonce",
    "0x0000000000000000000000000000000000000000000000000000000000000000"
]
}, { headers: { 'Content-Type': 'application/json' } });

console.log(response.data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'id': 'getblock.io',
        'method': 'state_call',
        'params': [
    "AccountNonceApi_account_nonce",
    "0x0000000000000000000000000000000000000000000000000000000000000000"
]
    }
)

print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .json(&json!({
            "jsonrpc": "2.0",
            "id": "getblock.io",
            "method": "state_call",
            "params": [
    "AccountNonceApi_account_nonce",
    "0x0000000000000000000000000000000000000000000000000000000000000000"
]
        }))
        .send().await?
        .json::<Value>().await?;
    println!("{}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x2a000000"
}

Response Fields

FieldTypeDescription
resultstringSCALE-encoded runtime API result (hex)

Use Cases

  • Runtime APIs: Call any exposed runtime API directly
  • Custom Queries: Reach data not exposed by a dedicated RPC
  • Tooling: Build typed helpers over runtime APIs

Error Handling

ErrorMessageDescription
-32603 / Internal errorExecution errorThe runtime API name or arguments are invalid
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect