i need to check in my dapp when the metadata of my wallet is expired and show a popup telling the user that he needs to update his metadata by clicking an update button on that popup.

i need to do this so that the user can always see all the transaction data when making a transaction, if the metadata is not updated he will see some hex code.

How can i update the metadata from inside my app using polkadot.js library ? Can i do this using some other library ? Is there any other library that is better than polkadot.js ?

1 Answer 1


So generally speaking Polkadot-js exposes two important Classes here that can be expanded upon for metadata: TypeRegistry, and Metadata. So the simple answer is yes: If you are using the ApiPromise (or even just the registry) you can update the metadata within the registry.

import { TypeRegistry, Metadata } from '@polkadot/types';

const registry = new TypeRegistry();
const metadata = new Metadata(registry, metaHex);

The following source code for v10.11.2 on setMetadata can be found here;

You can also use setMetadata to set your signedExtensions, and userExtensions. The noInitWarn param will suppress any warning the api might throw when setting the extrinsics and types within the registry.


The above answer is useful if you are already utilizing Polkadot-js as the tooling library for your dapp.

  • how do i check if the metadata is up to date ? what is metaHex and do i get it ? Commented Feb 12 at 10:06
  • 1
    metaHex is just the metadata value is as a scale encoded hexadecimal. You can get it by calling const metaHex = (await api.rpc.state.getMetadata()).toHex(). As for updating the metadata, here is a concise answer on checking the version of the metadata: substrate.stackexchange.com/a/1359/1786 One way you can go about this is everytime there is a runtime change, to just update the metadata.
    – Tarik Gul
    Commented Feb 12 at 14:01
  • could you explain me how do i check if there is a runtime change ? i want to: 1. check if i need to update the metadata in my dapp using polkadot.js 2. show popup asking to if i want to update the metadata 3. click update and in the background update the metadata to the latest version can you wrtie me down the code i need to run to do this ? Commented Feb 29 at 11:53

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.