If I make a request to get events in a particular block using web UI, I get a nice human-readable response:
I've made an RPC call to get the same data
{
"id": 1,
"jsonrpc": "2.0",
"method": "state_getStorageAt",
"params": ["0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7","0x5056c4cb701e192962e5a76c895273e69188edea1badf9b145b884a9416c8443"]
}
... and I got an output
{
"jsonrpc": "2.0",
"result": "0x1000000000000000585f8f090000000002000000010000000508ba6ef6480a2c4173bbbf0c27355c0e3c6d7a874a21cc2464e97d3fd5d92e245b1b5a7307000000000000000000000000000001000000080380eb30ca364f5c349d573b62cfadadba95af2e94f62fd8af4e15b90b971a4da633803b0648373051a1e2158c547112dcf63802d0d52b301a33dae8b9c6114e90f012b8516d57525358775a7476385956586574346e43424a396776646d4a6e3564364b34385a6a6148704763515a75676300000100000000001027000000000000000000",
"id": 1
}
I understand that it is a set of data encrypted with SCALE codec.
For example 0803
is a pallet and method indexes and
eb30ca364f5c349d573b62cfadadba95af2e94f62fd8af4e15b90b971a4da633
is attached data.
What is the best way to decode the complete result with Rust? Thanks
UPDATE
In the end this worked for me
#[subxt::subxt(runtime_metadata_path = "metadata.scale")]
pub mod polkadot {}
let data = "0x0c00000000000000585f8f090000000002000000010000000508ba6ef6480a2c4173bbbf0c27355c0e3c6d7a874a21cc2464e97d3fd5d92e245bd859730700000000000000000000000000000100000000010308011027000000000000000000";
let data_bytes = hex::decode(data.replace("0x", "")).unwrap();
let event = <polkadot::system::storage::Events as StorageEntry>::Value::decode(&mut data_bytes.as_slice()).unwrap();