Skip to content

Support decoding Extrinsics in blocks? #622

@jsdw

Description

@jsdw

We can access the bytes in each block with eg api.blocks().at(hash).await?.body().await?.extrinsics(). This returns an iterator over each extrinsic in the block. From this you can call extrinsic.bytes() to get the bytes for the extrinsic.

Extrinsic bytes consist of a signature and such, and then additional details, and then the call data.

It'd be nice if we could expand this Extrinsic interface to include functions similar to EventDetails. This is one idea:

// get bytes representing the fields (call data)
ext.field_bytes()

// indexes, like events
ext.pallet_index()
ext.variant_index()

// maybe these too from EventDetails?
// decode into a specific call data entry
ext.as_call()
// decode into a specific pallet Call enum (can decode to Value)
ext.as_pallet_call()
// decode into a top level generated calls enum.
ext.as_root_call()

We could also (possibly later) extend with methods to access the signature part of the extrinsic.

This would only work for blocks that we can decode with the currently supported metadata version etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions