state_getMetadata - JSON-RPC Method
Returns the runtime metadata as a SCALE-encoded hex string. Use libraries like polkadot.js to decode.
Code Examples
- cURL
- TypeScript (polkadot.js)
curl ${S.rpcBase} \
-X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"state_getMetadata","params":[],"id":1}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('${S.wsBase}');
const api = await ApiPromise.create({ provider });
const metadata = await api.rpc.state.getMetadata();
console.log(metadata.toHuman());
await api.disconnect();