As an example, getPastLogs
defines topics
parameter as:
topics - Array: An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use null, e.g.
[null, '0x12...']
. You can also pass an array for each topic with options for that topic e.g.[null, ['option1', 'option2']]
If I mean reading this right, then:
['0x12...']
will filter by0x12...
topic.[null, '0x12...']
will match all topics, and filter by index parameters.
I don't comprehend the [null, ['option1', 'option2']]
example though.
Currently, I am doing it as such:
const [syncLogs, swapLogs] = await Promise.all([
web3.eth.getPastLogs({
fromBlock: firstBlockNumber,
toBlock: firstBlockNumber,
topics: [
syncToken.signature,
],
}),
web3.eth.getPastLogs({
fromBlock: firstBlockNumber,
toBlock: firstBlockNumber,
topics: [
swapToken.signature,
],
}),
]);
Though this results in two distinct JSON-RPC calls.
Is there a way to filter by multiple topics?