I want to decode the contract call data and event data saved in a block. How can I do that?
2 Answers
Having this data in hex format, you can decode it using cargo-contract command line utility simply like this (run from the contract src folder):
cargo contract decode -d <data_hex_string> -t message
You can decode event and constructor data in the same way by running it with -t event
and -t constructor
accordingly.
-
Also, note that
cargo contract decode
cannot know which event to decode as the 'data' does not contain the event id. See substrate.stackexchange.com/questions/8316/…. Commented May 8, 2023 at 11:13
Typically all data is SCALE encoded for Substrate. You need to decode and parse the result into something human readable, like is done on the contracts-ui from the contracts-ui github and documented in the polkadot-js contracts docs