4

Hello guys i am trying to get the metadata as a 0x${string} type. I am calling the api endpoint state_getMetadata with await api.rpc.state.getMetadata() however this returns an object of Metadata and i am trying to do offline singing of transctions.

I have followed the github examples where they are doing same thing however when i try to sign the transaction it wants the metadata to be of type 0x${string} how do i properly convert or implement this?

thanks in advance

1 Answer 1

5

In order to have the return value of await api.rpc.state.getMetadata() be a type of 0x${string} all you need to do is call .toHex() on the return type.

So:

const metadata = await api.rpc.state.getMetadata();
const metadataHex = metadata.toHex();

Your Answer

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

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