state_call - JSON-RPC Method
Description
Invokes a runtime API exposed by the Enjin Matrix runtime. Calls are executed against the node's current state and return SCALE-encoded responses. Typical uses include querying the runtime metadata (Metadata_metadata
), fetching session information, or invoking custom APIs without submitting extrinsics.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
method | string | Yes | Name of the runtime API function (e.g., Metadata_metadata ) |
data | string | Yes | Hex-encoded SCALE input payload |
blockHash | string | null | No | Block hash for historical calls |
Returns
Field | Type | Description |
---|---|---|
result | string | SCALE-encoded return value |
Request Example
{
"jsonrpc": "2.0",
"method": "state_call",
"params": [
"Metadata_metadata",
"0x",
null
],
"id": 1
}
Response Example (truncated)
{
"jsonrpc": "2.0",
"result": "0x526916006d6574610e610d000c1c73705f636f72651863727970746f2c4163636f756e7449643332...",
"id": 1
}
The response is the same SCALE blob returned by state_getMetadata
and can be decoded with the same tooling.
Code Examples
cURL
curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "state_call",
"params": ["Metadata_metadata", "0x", null],
"id": 1
}'
JavaScript (Polkadot.js)
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({ provider: new WsProvider('wss://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY') });
const metadataHex = await api.rpc.state.call('Metadata_metadata', '0x');
console.log(metadataHex.slice(0, 66));
Python (requests + scalecodec)
payload = {
"jsonrpc": "2.0",
"method": "state_call",
"params": ["Metadata_metadata", "0x", None],
"id": 1,
}
metadata_hex = requests.post(
"https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY",
headers={"Content-Type": "application/json"},
data=json.dumps(payload),
timeout=20,
).json()["result"]
# Decode with scalecodec.MetadataDecoder as shown in state_getMetadata
Tips
- Ensure inputs are SCALE-encoded. Many runtime APIs expect tuples or composites; consult metadata to build the payload.
- Blocking methods may be disabled on public RPC endpoints; run against a trusted node when invoking privileged APIs.
- Combine with
state_callAt
(viablockHash
) to inspect past runtime behaviour.