state_call
Calls a runtime API method on Asset Hub.
Use Cases#
- Runtime computations - Execute runtime logic without transactions
- Account queries - Use AccountNonceApi for native stablecoin transfers (USDC, USDT), DOT staking and governance, and cross-chain asset management via XCM
- 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 https://api-asset-hub-polkadot.n.dwellir.com/<YOUR_API_KEY>/YOUR_API_KEY \
-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('wss://api-asset-hub-polkadot.n.dwellir.com/YOUR_API_KEY');
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