Skip to main content

state_getMetadata

Description#

Returns the SCALE-encoded metadata for the current runtime. Decode with polkadot.js, subxt, or py-substrate-interface to obtain pallet calls, storage keys, and events.

Parameters#

PositionTypeDescription
0 (optional)stringBlock hash to query. Omit to fetch latest metadata.

Request Example#

{
"jsonrpc": "2.0",
"method": "state_getMetadata",
"params": [],
"id": 1
}

Response Example (truncated)#

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x6d6574610c73797374656d0400…"
}

The result hex string exceeds several hundred kilobytes. Always decode using tooling rather than embedding raw strings in code.

Code Examples#

substrate = SubstrateInterface(url="wss://api-astar.n.dwellir.com/YOUR_API_KEY", ss58_format=5)
metadata = substrate.get_metadata()
print("Metadata version", metadata.metadata_version)