state_call
Calls a runtime API method on Kusama.
Use Cases#
- Runtime computations - Execute runtime logic without transactions
- Account queries - Use AccountNonceApi for parachain experimentation, early feature deployment, and production-grade testing with real value
- Fee estimation - Use TransactionPaymentApi
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
method | String | Yes | Runtime API method name |
data | String | Yes | SCALE-encoded call data |
blockHash | String | No | Block hash for historical call |
Request#
{
"jsonrpc": "2.0",
"method": "state_call",
"params": ["AccountNonceApi_account_nonce", "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"],
"id": 1
}
Code Examples#
- cURL
- JavaScript
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_call",
"params": ["AccountNonceApi_account_nonce", "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('');
const api = await ApiPromise.create({ provider });
// Get account nonce via runtime API
const account = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const result = await api.call.accountNonceApi.accountNonce(account);
console.log('Account nonce:', result.toNumber());
await api.disconnect();
Related Methods#
state_getStorage- Query storagestate_getMetadata- Get runtime metadata