Skip to main content

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#

ParameterTypeRequiredDescription
methodstringYesRuntime API method, e.g., AccountNonceApi_accountNonce
datastringYesHex-encoded SCALE parameters
blockHashstringNoBlock hash for a historical query

Returns#

FieldTypeDescription
resultstringSCALE-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#

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 or HyperbridgeApi before decoding.
  • Pin calls to a specific block hash when you require deterministic snapshots (e.g., fee history or reward curves).