The common way of generated type augmentation is by fetching the latest metadata from a running node with the following piece of code:

await provider.connect()
await provider.isReady
const result = await provider.send('state_getMetadata')

The return type of the call seems to be an object with the following structure:

  "result": <scale_and_hex_encoded_metadata>

On the resulting JSON file, some variation of the ts-node --skip-project ../../node_modules/.bin/polkadot-types-from-defs is to be run.

We want to expose the generated metadata for a built WASM using subwasm, with subwasm metadata --json <runtime_wasm>, which generates metadata in the following format:

  "V14": {
    "types": {...},
    "pallets": [...],
    "extrinsic": {...},
    "ty": 232

What is the way to use this metadata format to generate the augmented types? Do we need to apply some sort of encoding on the data before calling the polkadot-types-from-defs script? If so, what is the process? The RPC node seems to be returning a MagicNumber which the script expects, and I could not find much information about it.

1 Answer 1


The latest release of subwasm contains a flag --format=json+scale which will return exactly the {"result": "<scale and hex encoded metadata>"} that is needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.