โš ๏ธBlast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today โ†’
Skip to main content

state_call

Descriptionโ€‹

Invokes a runtime API method directly. This is required for advanced features such as Frontier EVM tracing, node benchmarking, or parachain host queries.

Parametersโ€‹

PositionTypeDescription
0stringRuntime API function name (e.g., TransactionPaymentApi_queryInfo)
1stringSCALE-encoded parameters
2 (optional)stringBlock hash to execute against

Example: Query transaction payment info via runtime APIโ€‹

The runtime exposes TransactionPaymentApi_queryInfo. The first parameter is the encoded extrinsic, the second is the length (u32). The helper below shows how to build the payload using polkadot.js.

import { ApiPromise, WsProvider } from '@polkadot/api';
import { u32 } from '@polkadot/types';

const api = await ApiPromise.create({ provider: new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY') });
const tx = api.tx.balances.transferKeepAlive(dest, amount);
const encoded = tx.toHex();
const len = api.createType('u32', encoded.slice(2).length / 2).toHex();

const result = await api.rpc.state.call('TransactionPaymentApi_queryInfo', encoded + len.slice(2));
console.log(result.toHuman());

Pitfallsโ€‹

  • Arguments must be SCALE-encoded and concatenated; use type helpers from polkadot.js or subxt.
  • Names are case-sensitive and must match metadata. Enumerate available APIs through state_getRuntimeVersion().apis.
  • Public RPC providers may limit heavy runtime callsโ€”run self-hosted nodes for profiling.