The events are stored on chain as a Vec<EventRecord>
- this means that when you make a query (either for latest or for a specific blockHash), that you would get set for that specific block. The RPCs itself has no filtering mechanism, it simply returns what is available in the state.
With this in mind, any filtering would need to be performed once the Vec
is returned, which mean on the client side. Additionally, since each runtime is different and events are specific to a pallet, specific per-account filtering is also left up to the client. The RPC returns really views this as "opaque", it just returns the data in the state, specific records are only understandable alongside the metadata.
With this in mind, what you can do is to filter for the specific events you are interested in. As an example using the JS API and looking at balances.Deposit events -
// retrieve all events
const all = await api.query.system.events();
// filter the balances.Deposit events
const deposits = all.filter(({ event }) =>
api.events.balances.Deposit.is(event)
);
// display the recipient & amounts
for (let i = 0; i < deposits.length; i++) {
const [recipient, amount] = deposits.event.data;
console.log(recipient.toString() + ' received ' + amount.toString());
}
For each specific event type you are interested in, you would need to -
- check for the specific event
- extract the parameters as per the event specification