1

Hello I am creating custom rpc call, I need metadata to be able to decode extrinsics call inside my calls.

But I don't know how to get substrate metadata inside my rpc call?

3
  • Could you explain a little bit what your RPC call would do? or what is the expected input/output
    – andresvsm
    Commented Aug 11, 2022 at 9:06
  • Yes, sur in a custom rpc method, I am getting the extrinsics of a block, and I need to decode those extrinsics, but to do that I need to use Metadata. :-)
    – cibou
    Commented Aug 11, 2022 at 11:11
  • I see, it's interesting, but I would keep decoding processes outside of the custom RPC calls. It will affect the node performance under heavy loads of requests, as it will have to decode each time an RPC call is made. As Iker mentioned, you can perform this decoding process off chain, but that's just a suggestion. I look forward to see if anyone can help here!
    – andresvsm
    Commented Aug 12, 2022 at 6:41

1 Answer 1

3

Conveniently, you have the relevant RPC method to get the metadata from a Substrate chain as the first example of the custom RPC documentation on Substrate.

Additionally, if you are considering to use Polkadot.js, this is the relevant method to get the metadata.

Finally, this answer should cover how to do this in a custom RPC call.

5
  • Thank you @Iker but I would like to do that in rust inside my custom RPC :-)
    – cibou
    Commented Aug 10, 2022 at 12:28
  • 1
    Perhaps this guide from my colleagues in support helps you building a custom RPC for your purposes: hackmd.io/JpJCbu0nTa2jym0za1Tggw Let me know if it helps.
    – Iker
    Commented Oct 5, 2022 at 7:22
  • thank you I will take a look.
    – cibou
    Commented Oct 5, 2022 at 7:33
  • 1
    Hey @Iker, you might also like to consider looking at the subxt rust library, which provides similar functions to PolkadotJS but in rust: github.com/paritytech/subxt
    – insipx
    Commented Nov 27, 2022 at 18:28
  • and this is the function you would use I think: docs.rs/subxt/0.25.0/subxt/rpc/struct.Rpc.html#method.metadata
    – insipx
    Commented Nov 27, 2022 at 18:45

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.