For the complete documentation index, see llms.txt. This page is also available as Markdown.

state_getMetadata - Midnight

Example code for the state_getMetadata JSON-RPC method. Complete guide on how to use state_getMetadata JSON-RPC in GetBlock Web3 documentation.

This method returns the SCALE-encoded runtime metadata. Metadata describes all pallets, calls, events, errors, storage layouts, and types in the runtime — clients use it to decode chain data.

Parameters

Parameter
Type
Required
Description

hash

string

No

Block hash to query metadata at. Defaults to the current best block

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "state_getMetadata",
    "params": [],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x6d65746114180c1c73797374656d\u2026"
}

Response Parameters

Field
Type
Description

result

string

Hex-encoded SCALE-serialized metadata

Use Cases

  • Bootstrapping a typed client (Polkadot.js, subxt, substrate-interface)

  • Decoding extrinsics, events, and storage values

  • Detecting metadata changes between runtime versions

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?