Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

How to decode an extrinsic in the client? #9823

Answered by Voxelot
nazar-pc asked this question in Q&A
Discussion options

You must be logged in to vote

The most straightforward way is to deserialize as an UncheckedExtrinsic that you've configured for your runtime. For example, you could add a deserialize_opaque_extrinsic fn to your main runtime/lib.rs.

use parity_scale_codec::{Decode, Encode};
use sp_runtime::generic;

pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
// Where Call comes from `construct_runtime!`
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;

pub fn deserialize_opaque_extrinsic(opaque_ext: OpaqueExtrinsic) -> Result<UncheckedExtrinsic, parity_scale_codec::Error> {
    let bytes = some_opaque_extrinsic.encode();
    UncheckedExtrinsic::decode(&mut bytes.as_slic…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@nazar-pc
Comment options

Answer selected by nazar-pc
Comment options

You must be logged in to vote
1 reply
@nazar-pc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants