⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
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

JavaScript (polkadot.js)

const api = await ApiPromise.create({ provider: new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY') });
await api.isReady;
const metadata = api.runtimeMetadata;
console.log('Metadata version', metadata.version);

Rust (subxt)

let api = OnlineClient::<SubstrateConfig>::from_url("wss://api-astar.n.dwellir.com/YOUR_API_KEY").await?;
let metadata = api.metadata();
println!("metadata version {}", metadata.version());

Python (py-substrate-interface)

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)