polkaj icon indicating copy to clipboard operation
polkaj copied to clipboard

How to decode extrinsics in a block

Open Pittzhang314 opened this issue 5 years ago • 6 comments

How to decode extrinsics in a block

Pittzhang314 avatar Sep 26 '20 12:09 Pittzhang314

@Pittzhang314 It depends on what you want to decode. In general there is the module polkaj-scale and docs for it https://github.com/emeraldpay/polkaj/blob/master/docs/02-encoding.adoc. Many standard types has an implemented decoder in module polkaj-scale-types, but mostly not covered withing the docs. Please take a look into the source, maybe it already have an implementation. If not you make a suggestion/PR or implement it independently

splix avatar Sep 28 '20 19:09 splix

use rpc method to fetch extrinsics by block , it's format will be like "0x410284d21a5689680a5e569d3c4370d2a94daab....."

but now I don't know how to convert this to byte[] , i'm now just use substring like "410284d21a5689680a5e569d3c4370d2a94daab....."

and use Hex.decode() to convert it to byte[] , but that will fail.

is there any idea to do this?

@splix

BomaxChen avatar Oct 07 '20 09:10 BomaxChen

@splix It means that if I get Block, that will fetch extrinsics lists, how do I know which is transfer or transfer_keep_alive extrinsics, and decode it to readable data. ( like sender, signature, success...)

BomaxChen avatar Oct 08 '20 04:10 BomaxChen

@splix I have already decode by BalanceTransferReader, the next i need to solve is previous question " how do i check extrinsics is transfer or transfer_keep_alive" .

and check this transfer is success or not.

Thank you a lot.

BomaxChen avatar Oct 08 '20 04:10 BomaxChen

@BomaxChen sorry, missed the questions here. But we continued the conversation on Gitter.

splix avatar Oct 08 '20 14:10 splix

@splix I have already decode by BalanceTransferReader, the next i need to solve is previous question " how do i check extrinsics is transfer or transfer_keep_alive" .

and check this transfer is success or not.

Thank you a lot.

how do you get the txhash? or how to get txhash from signature?

zengchao1212 avatar Sep 13 '21 10:09 zengchao1212