3

We are manually decoding the encoded extrinsic.

[ex 0x510284.. -> TransactionInfo{value=AccountID{address=14pT17...)]

It was confirmed that polkadot-js is well decoded through the toHuman method no matter what event extrinsic is given as an input value.

But in Java, I need to know the event type in advance like below.

// I need to know in advance that it is an event type called Balance Transfer.
ExtrinsicReader<BalanceTransfer> reader = new ExtrinsicReader<>(
                    new BalanceTransferReader(SS58Type.Network.LIVE),
                    SS58Type.Network.LIVE
            );

So my question is, can I infer the event type in advance from the encoded extrinsics? The reason I'm asking this question is because I found that the front of some extrinsics is similar for each event type

Otherwise, how can I do polkadot-js?

1 Answer 1

2

No, there is currently not a way to know which extrinsics would emit which event types, or what those events would mean.

FRAME provides a fully customizable programming environment, which means that a user can define any number of custom events, and can emit those events whenever they want in the middle of an extrinsic or other runtime processes.

They could even be totally nonsensical, for example emitting an event Balance.Transfer when no transfer has occurred... however this would make for a really shitty blockchain.

So really, you need to manually program associations with extrinsics and events to derive meaning from the events, and only by looking at the code of the extrinsic can you know what will be emitted, and when.

The only thing you can know for sure is that there will be events emitted from frame_system telling you whether an extrinsic succeeded or not, and that is the only constant output you can expect for any extrinsic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.