Complete the code to filter events by their name.
const filteredEvents = events.filter(event => event.[1] === 'Transfer');
The property name holds the event's name, so filtering by event.name === 'Transfer' selects only Transfer events.
Complete the code to filter events emitted by a specific address.
const filteredEvents = events.filter(event => event.[1] === '0x1234abcd');
The from property usually stores the address that emitted the event, so filtering by event.from === '0x1234abcd' selects events from that address.
Fix the error in the code to filter events with a value greater than 1000.
const bigValueEvents = events.filter(event => event.value [1] 1000);
To filter events where the value is greater than 1000, use the greater than operator >. Using = is an assignment, not a comparison.
Fill both blanks to filter events with a topic matching '0xabc' and a block number greater than 5000.
const filtered = events.filter(event => event.[1] === '0xabc' && event.[2] > 5000);
The topic property holds the event topic, and blockNumber holds the block number. Filtering by these selects events with the given topic and block number above 5000.
Fill all three blanks to create a dictionary of event counts by event name, filtering only events with value greater than 10.
const eventCounts = events.reduce((acc, event) => {
if (event.[1] > 10) {
acc[event.[2]] = (acc[event.[3]] || 0) + 1;
}
return acc;
}, {});We check if event.value is greater than 10, then count events by their name. The accumulator key uses event.name to count occurrences.