state_call
Invokes a runtime API function locally on the node and returns the SCALE-encoded result. Use this to access runtime helpers such as transaction fee estimation (TransactionPaymentApi_queryInfo
) or credential verifiers without mutating state.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
method | string | Yes | Runtime API function identifier (e.g., TransactionPaymentApi_queryInfo ). |
data | string | Yes | Hex-encoded SCALE payload expected by the runtime API. |
at | string | No | Block hash to execute the call against a historical state. |
Returns
Field | Type | Description |
---|---|---|
result | string | Hex-encoded SCALE bytes returned by the runtime API. |
Example (Transaction Fee Quote)
import { ApiPromise, WsProvider } from '@polkadot/api';
import { hexAddPrefix } from '@polkadot/util';
const provider = new WsProvider('wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
// Create a dummy balance transfer and scale-encode it
const call = api.tx.balances.transferKeepAlive('5E5d...Recipient', 1_000_000_000_000_000_000n);
const payload = call.toU8a();
const result = await api.rpc.state.call(
'TransactionPaymentApi_queryInfo',
hexAddPrefix(payload)
);
console.log('Fee info SCALE-encoded', result.toHex());
Raw JSON-RPC
{
"jsonrpc": "2.0",
"method": "state_call",
"params": [
"TransactionPaymentApi_queryInfo",
"0x280402000b50cd548d8501"
],
"id": 1
}
Usage Notes
- Always consult the runtime metadata to confirm the expected SCALE payload for the target API.
- Provide a finalized block hash through the optional third parameter when you require deterministic results for audits.
- Responses are SCALE-encoded; decode them with
@polkadot/api
orscale-codec
utilities.