state_call
Description
Executes a runtime API call with the given method name and SCALE-encoded parameters. Bifrost exposes runtime APIs for account nonce, staking metrics, omnipool quotes, and Hyperbridge operations. Responses are SCALE-encoded and must be decoded using the appropriate types.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
method | string | Yes | Runtime API method, e.g., AccountNonceApi_accountNonce |
data | string | Yes | Hex-encoded SCALE parameters |
blockHash | string | No | Block hash for a historical query |
Returns
Field | Type | Description |
---|---|---|
result | string | SCALE-encoded response |
Request Example
{
"jsonrpc": "2.0",
"method": "state_call",
"params": [
"AccountNonceApi_accountNonce",
"0x1400000000000000000000000000000000000000000000000000000000000000"
],
"id": 1
}
Response Example
{
"jsonrpc": "2.0",
"result": "0x04000000",
"id": 1
}
Decoded, the nonce equals 4
for the supplied account.
Code Examples
JavaScript (polkadot.js)
const codec = await api.rpc.state.call('OmnipoolApi_quotePrice', paramsBytes);
const quote = api.createType('u128', codec).toString();
Python (py-substrate-interface)
from scalecodec.type_registry import load_type_registry_file
from substrateinterface import SubstrateInterface
substrate = SubstrateInterface(
url="wss://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY",
type_registry=load_type_registry_file('custom/bifrost.json')
)
runtime_result = substrate.rpc_request(
method='state_call',
params=['OmnipoolApi_quotePrice', '0x....']
)
print(runtime_result['result'])
Usage Notes
- Ensure you include the correct type registry for custom APIs such as
OmnipoolApi
orHyperbridgeApi
before decoding. - Pin calls to a specific block hash when you require deterministic snapshots (e.g., fee history or reward curves).