I'm wondering if there is any way to extract information about method and parameter of Extrinsic(Unchecked/CheckedExtrinsic) using TypeInfo and Scale codec.

In polkadotJs there is toString method on tx that can be used to represent extrinsic as a JSON and fetch info about method/params.


Essentially I would like to fetch same info at the rust side (in runtime).

One way to do it is would be to implement new trait for RuntimeCall that would return

pub trait GetMethodName{
fn (&self) -> String;

And implementing it in Runtime, so something like

impl MethodName for RuntimeCall {
    fn into(self) -> CallType {
        match self {
            RuntimeCall::FooPallet(pallet_foo::Call::foo {}) => "foo".to_string(),

But I'm pretty sure there should be a way to utilize Scale codec and TypeInfo

2 Answers 2


I'm not sure of the context in which you want this information, but if you're just keen to connect to a node/chain, download blocks and decode extrinsics, then have a look at Subxt, which is a Rust library for interacting with nodes/chains.

This example inparticular downloads blocks and prints a bunch of information about them:


If you just want to understand which calls (and more) are available on a node, then the Subxt CLI tool has a nice explore command which can be pointed at a node and give information about it (cargo install subxt-cli). We have also been working on a UI to explore this information here: https://paritytech.github.io/subxt-explorer/

Internally, this all relies on obtaining the metadata from a node (the Subxt CLI command has a metadata option to download this for you), and then decoding it (the SCALE encoded metadata can be decoded via parity-scale-codec to this).

The metadata contains TypeInfo for all relevant types, as well as information on things like which calls are available in each pallet. Calls are basically represented as a Variant type, where the variant names are the call names and the variant fields are the arguments to the call (see the scale-info docs for more on what the type info contains).

  • Hi, thanks for a quick response, but what i need is to get name of the extrinsic and its params in a generic way in node runtime not outside of the node ;/ Nov 24, 2023 at 5:55

I got an answer on github so copying it here for the record

Types annotated with #[derive(TypeInfo)] end up with a MyType::type_info() method. Look through the docs there and you'll see how to obtain various information about the type.

You can't get any information about values though; the macro doesn't know anything about the values of a particular instance. All you get is the type information which is tied to how some instance of that type would be SCALE encoded via parity-scale-codec.

If you have some SCALE encoded bytes already, and you have a scale_info::PortableRegistry describing the shape of those bytes (this can be constructed from some TypeInfos), then libraries like scale-decode can be used to decode those bytes into some type (anything implementing DecodeAsType which has a compatible shape), and building on that, scale-value offers a Value type which is one such target that any SCALE encoded bytes can decode into, and can then be iterated over or whatever to explore the value.

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.